Springer Series in Statistics

Trevor Hastie • Robert Tibshirani • Jerome Friedman
The Elements of Statictical Learning

During the past decade there has been an explosion in computation and information tech-
nology. With it have come vast amounts of data in a variety of fields such as medicine, biolo-
gy, finance, and marketing. The challenge of understanding these data has led to the devel-
opment of new tools in the field of statistics, and spawned new areas such as data mining,
machine learning, and bioinformatics. Many of these tools have common underpinnings but
are often expressed with different terminology. This book describes the important ideas in
these areas in a common conceptual framework. While the approach is statistical, the
emphasis is on concepts rather than mathematics. Many examples are given, with a liberal
use of color graphics. It should be a valuable resource for statisticians and anyone interested
in data mining in science or industry. The book’s coverage is broad, from supervised learning
(prediction) to unsupervised learning. The many topics include neural networks, support
vector machines, classification trees and boosting—the first comprehensive treatment of this
topic in any book.

This major new edition features many topics not covered in the original, including graphical
models, random forests, ensemble methods, least angle regression & path algorithms for the
lasso, non-negative matrix factorization, and spectral clustering. There is also a chapter on
methods for “wide” data (p bigger than n), including multiple testing and false discovery rates.

Trevor Hastie, Robert Tibshirani, and Jerome Friedman are professors of statistics at
Stanford University. They are prominent researchers in this area: Hastie and Tibshirani
developed generalized additive models and wrote a popular book of that title. Hastie co-
developed much of the statistical modeling software and environment in R/S-PLUS and
invented principal curves and surfaces. Tibshirani proposed the lasso and is co-author of the
very successful An Introduction to the Bootstrap. Friedman is the co-inventor of many data-
mining tools including CART, MARS, projection pursuit and gradient boosting.

S T A T I S T I C S

isbn 978-0-387-84857-0

› springer.com

H
a
s
t
i
e
•
T
i
b
s
h
i
r
a
n

i

•
F
r
i
e
d
m
a
n

T
h
e
E
l
e
m
e
n
t
s
o
f
S
t
a
t
i
s
t
i
c
a
l
L
e
a
r
n
n
g

i

Springer Series in Statistics

Trevor Hastie
Robert Tibshirani
Jerome Friedman

The Elements of
Statistical Learning
Data Mining, Inference, and Prediction

Second Edition

 
 
 
 
 
 
 
 
This is page v
Printer: Opaque this

To our parents:

Valerie and Patrick Hastie

Vera and Sami Tibshirani

Florence and Harry Friedman

and to our families:

Samantha, Timothy, and Lynda

Charlie, Ryan, Julie, and Cheryl

Melanie, Dora, Monika, and Ildiko

vi

Preface to the Second Edition

This is page vii
Printer: Opaque this

In God we trust, all others bring data.

–William Edwards Deming (1900-1993)1

We have been gratiﬁed by the popularity of the ﬁrst edition of The
Elements of Statistical Learning. This, along with the fast pace of research
in the statistical learning ﬁeld, motivated us to update our book with a
second edition.

We have added four new chapters and updated some of the existing
chapters. Because many readers are familiar with the layout of the ﬁrst
edition, we have tried to change it as little as possible. Here is a summary
of the main changes:

1On the Web, this quote has been widely attributed to both Deming and Robert W.
Hayden; however Professor Hayden told us that he can claim no credit for this quote,
and ironically we could ﬁnd no “data” conﬁrming that Deming actually said this.

viii

Preface to the Second Edition

Chapter
1. Introduction
2. Overview of Supervised Learning
3. Linear Methods for Regression

4. Linear Methods for Classiﬁcation
5. Basis Expansions and Regulariza-
tion
6. Kernel Smoothing Methods
7. Model Assessment and Selection

8. Model Inference and Averaging
9. Additive Models, Trees, and
Related Methods
10. Boosting and Additive Trees

11. Neural Networks

12. Support Vector Machines and
Flexible Discriminants
13.
Nearest-Neighbors
14. Unsupervised Learning

Prototype Methods

and

15. Random Forests
16. Ensemble Learning
17. Undirected Graphical Models
18. High-Dimensional Problems

Some further notes:

What’s new

LAR algorithm and generalizations
of the lasso
Lasso path for logistic regression
Additional illustrations of RKHS

Strengths and pitfalls of
validation

cross-

New example from ecology; some
material split oﬀ to Chapter 16.
Bayesian neural nets and the NIPS
2003 challenge
Path algorithm for SVM classiﬁer

dimension

Spectral clustering, kernel PCA,
sparse PCA, non-negative matrix
analysis,
factorization archetypal
nonlinear
reduction,
Google page
rank algorithm, a
direct approach to ICA
New
New
New
New

•

•

•

Our ﬁrst edition was unfriendly to colorblind readers; in particular,
we tended to favor red/green contrasts which are particularly trou-
blesome. We have changed the color palette in this edition to a large
extent, replacing the above with an orange/blue contrast.

We have changed the name of Chapter 6 from “Kernel Methods” to
“Kernel Smoothing Methods”, to avoid confusion with the machine-
learning kernel method that is discussed in the context of support vec-
tor machines (Chapter 11) and more generally in Chapters 5 and 14.

In the ﬁrst edition, the discussion of error-rate estimation in Chap-
ter 7 was sloppy, as we did not clearly diﬀerentiate the notions of
conditional error rates (conditional on the training set) and uncondi-
tional rates. We have ﬁxed this in the new edition.

Preface to the Second Edition

ix

•

•

•

Chapters 15 and 16 follow naturally from Chapter 10, and the chap-
ters are probably best read in that order.

In Chapter 17, we have not attempted a comprehensive treatment
of graphical models, and discuss only undirected models and some
new methods for their estimation. Due to a lack of space, we have
speciﬁcally omitted coverage of directed graphical models.

Chapter 18 explores the “p
N ” problem, which is learning in high-
dimensional feature spaces. These problems arise in many areas, in-
cluding genomic and proteomic studies, and document classiﬁcation.

≫

We thank the many readers who have found the (too numerous) errors in
the ﬁrst edition. We apologize for those and have done our best to avoid er-
rors in this new edition. We thank Mark Segal, Bala Rajaratnam, and Larry
Wasserman for comments on some of the new chapters, and many Stanford
graduate and post-doctoral students who oﬀered comments, in particular
Mohammed AlQuraishi, John Boik, Holger Hoeﬂing, Arian Maleki, Donal
McMahon, Saharon Rosset, Babak Shababa, Daniela Witten, Ji Zhu and
Hui Zou. We thank John Kimmel for his patience in guiding us through this
new edition. RT dedicates this edition to the memory of Anna McPhee.

Trevor Hastie
Robert Tibshirani
Jerome Friedman

Stanford, California
August 2008

x

Preface to the Second Edition

Preface to the First Edition

This is page xi
Printer: Opaque this

We are drowning in information and starving for knowledge.

–Rutherford D. Roger

The ﬁeld of Statistics is constantly challenged by the problems that science
and industry brings to its door. In the early days, these problems often came
from agricultural and industrial experiments and were relatively small in
scope. With the advent of computers and the information age, statistical
problems have exploded both in size and complexity. Challenges in the
areas of data storage, organization and searching have led to the new ﬁeld
of “data mining”; statistical and computational problems in biology and
medicine have created “bioinformatics.” Vast amounts of data are being
generated in many ﬁelds, and the statistician’s job is to make sense of it
all: to extract important patterns and trends, and understand “what the
data says.” We call this learning from data.

The challenges in learning from data have led to a revolution in the sta-
tistical sciences. Since computation plays such a key role, it is not surprising
that much of this new development has been done by researchers in other
ﬁelds such as computer science and engineering.

The learning problems that we consider can be roughly categorized as
either supervised or unsupervised. In supervised learning, the goal is to pre-
dict the value of an outcome measure based on a number of input measures;
in unsupervised learning, there is no outcome measure, and the goal is to
describe the associations and patterns among a set of input measures.

xii

Preface to the First Edition

This book is our attempt to bring together many of the important new
ideas in learning, and explain them in a statistical framework. While some
mathematical details are needed, we emphasize the methods and their con-
ceptual underpinnings rather than their theoretical properties. As a result,
we hope that this book will appeal not just to statisticians but also to
researchers and practitioners in a wide variety of ﬁelds.

Just as we have learned a great deal from researchers outside of the ﬁeld
of statistics, our statistical viewpoint may help others to better understand
diﬀerent aspects of learning:

There is no true interpretation of anything; interpretation is a
vehicle in the service of human comprehension. The value of
interpretation is in enabling others to fruitfully think about an
idea.

–Andreas Buja

We would like to acknowledge the contribution of many people to the
conception and completion of this book. David Andrews, Leo Breiman,
Andreas Buja, John Chambers, Bradley Efron, Geoﬀrey Hinton, Werner
Stuetzle, and John Tukey have greatly inﬂuenced our careers. Balasub-
ramanian Narasimhan gave us advice and help on many computational
problems, and maintained an excellent computing environment. Shin-Ho
Bang helped in the production of a number of the ﬁgures. Lee Wilkinson
gave valuable tips on color production. Ilana Belitskaya, Eva Cantoni, Maya
Gupta, Michael Jordan, Shanti Gopatam, Radford Neal, Jorge Picazo, Bog-
dan Popescu, Olivier Renaud, Saharon Rosset, John Storey, Ji Zhu, Mu
Zhu, two reviewers and many students read parts of the manuscript and
oﬀered helpful suggestions. John Kimmel was supportive, patient and help-
ful at every phase; MaryAnn Brickner and Frank Ganz headed a superb
production team at Springer. Trevor Hastie would like to thank the statis-
tics department at the University of Cape Town for their hospitality during
the ﬁnal stages of this book. We gratefully acknowledge NSF and NIH for
their support of this work. Finally, we would like to thank our families and
our parents for their love and support.

Trevor Hastie
Robert Tibshirani
Jerome Friedman

Stanford, California
May 2001

The quiet statisticians have changed our world; not by discov-
ering new facts or technical developments, but by changing the
ways that we reason, experiment and form our opinions ....

–Ian Hacking

Contents

This is page xiii
Printer: Opaque this

Preface to the Second Edition

Preface to the First Edition

1 Introduction

2 Overview of Supervised Learning

2.1
2.2
2.3

2.4
2.5
2.6

2.7

Introduction . . . . . . . . . . . . . . . . . . . . . . . . .
Variable Types and Terminology . . . . . . . . . . . . . .
Two Simple Approaches to Prediction:
. . . . . . . . . . .
Least Squares and Nearest Neighbors
Linear Models and Least Squares
. . . . . . . .
2.3.1
Nearest-Neighbor Methods . . . . . . . . . . . .
2.3.2
2.3.3
From Least Squares to Nearest Neighbors . . . .
Statistical Decision Theory . . . . . . . . . . . . . . . . .
Local Methods in High Dimensions . . . . . . . . . . . . .
Statistical Models, Supervised Learning
and Function Approximation . . . . . . . . . . . . . . . .
2.6.1

A Statistical Model
for the Joint Distribution Pr(X, Y )
. . . . . . .
Supervised Learning . . . . . . . . . . . . . . . .
Function Approximation . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
Diﬃculty of the Problem . . . . . . . . . . . . .

2.6.2
2.6.3
Structured Regression Models
2.7.1

vii

xi

1

9
9
9

11
11
14
16
18
22

28

28
29
29
32
32

xiv

Contents

2.8

Classes of Restricted Estimators . . . . . . . . . . . . . .
. . .
Roughness Penalty and Bayesian Methods
2.8.1
Kernel Methods and Local Regression . . . . . .
2.8.2
. . . .
Basis Functions and Dictionary Methods
2.8.3
2.9 Model Selection and the Bias–Variance Tradeoﬀ . . . . .
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . .
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3 Linear Methods for Regression

3.1
3.2

3.3

3.4

Introduction . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
Linear Regression Models and Least Squares
Example: Prostate Cancer
3.2.1
. . . . . . . . . . . .
The Gauss–Markov Theorem . . . . . . . . . . .
3.2.2
Multiple Regression
3.2.3
from Simple Univariate Regression . . . . . . . .
3.2.4
. . . . . . . . . . . . . . . . .
Multiple Outputs
Subset Selection . . . . . . . . . . . . . . . . . . . . . . .
Best-Subset Selection . . . . . . . . . . . . . . .
3.3.1
Forward- and Backward-Stepwise Selection . . .
3.3.2
Forward-Stagewise Regression . . . . . . . . . .
3.3.3
3.3.4
. .
Prostate Cancer Data Example (Continued)
Shrinkage Methods . . . . . . . . . . . . . . . . . . . . . .
Ridge Regression . . . . . . . . . . . . . . . . .
3.4.1
The Lasso . . . . . . . . . . . . . . . . . . . . .
3.4.2
Discussion: Subset Selection, Ridge Regression
3.4.3
and the Lasso . . . . . . . . . . . . . . . . . . .
Least Angle Regression . . . . . . . . . . . . . .
. . . . . . . . .
Principal Components Regression . . . . . . . .
Partial Least Squares . . . . . . . . . . . . . . .

3.5.1
3.5.2

3.4.4

3.5 Methods Using Derived Input Directions

3.6 Discussion: A Comparison of the Selection

and Shrinkage Methods . . . . . . . . . . . . . . . . . . .
3.7 Multiple Outcome Shrinkage and Selection . . . . . . . .
3.8 More on the Lasso and Related Path Algorithms . . . . .
3.8.1
Incremental Forward Stagewise Regression . . .
3.8.2
Piecewise-Linear Path Algorithms . . . . . . . .
3.8.3
The Dantzig Selector
. . . . . . . . . . . . . . .
3.8.4
The Grouped Lasso . . . . . . . . . . . . . . . .
3.8.5
Further Properties of the Lasso . . . . . . . . . .
Pathwise Coordinate Optimization . . . . . . . .
3.8.6
3.9
Computational Considerations . . . . . . . . . . . . . . .
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . .
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

33
34
34
35
37
39
39

43
43
44
49
51

52
56
57
57
58
60
61
61
61
68

69
73
79
79
80

82
84
86
86
89
89
90
91
92
93
94
94

Contents

xv

4 Linear Methods for Classiﬁcation

4.4

4.1
4.2
4.3

101
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 101
Linear Regression of an Indicator Matrix . . . . . . . . . 103
Linear Discriminant Analysis . . . . . . . . . . . . . . . . 106
Regularized Discriminant Analysis . . . . . . . . 112
4.3.1
Computations for LDA . . . . . . . . . . . . . . 113
4.3.2
4.3.3
Reduced-Rank Linear Discriminant Analysis . . 113
Logistic Regression . . . . . . . . . . . . . . . . . . . . . . 119
Fitting Logistic Regression Models . . . . . . . . 120
4.4.1
. . . . . 122
Example: South African Heart Disease
4.4.2
Quadratic Approximations and Inference . . . . 124
4.4.3
L1 Regularized Logistic Regression . . . . . . . . 125
4.4.4
4.4.5
Logistic Regression or LDA? . . . . . . . . . . . 127
Separating Hyperplanes . . . . . . . . . . . . . . . . . . . 129
Rosenblatt’s Perceptron Learning Algorithm . . 130
4.5.1
Optimal Separating Hyperplanes . . . . . . . . . 132
4.5.2
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 135
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

4.5

5 Basis Expansions and Regularization

5.5

5.3
5.4

5.1
5.2

139
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 139
Piecewise Polynomials and Splines . . . . . . . . . . . . . 141
Natural Cubic Splines . . . . . . . . . . . . . . . 144
5.2.1
Example: South African Heart Disease (Continued)146
5.2.2
5.2.3
Example: Phoneme Recognition . . . . . . . . . 148
Filtering and Feature Extraction . . . . . . . . . . . . . . 150
Smoothing Splines . . . . . . . . . . . . . . . . . . . . . . 151
5.4.1
Degrees of Freedom and Smoother Matrices . . . 153
Automatic Selection of the Smoothing Parameters . . . . 156
5.5.1
Fixing the Degrees of Freedom . . . . . . . . . . 158
The Bias–Variance Tradeoﬀ . . . . . . . . . . . . 158
5.5.2
Nonparametric Logistic Regression . . . . . . . . . . . . . 161
. . . . . . . . . . . . . . . . . . 162
. 167
. . . 168
Spaces of Functions Generated by Kernels
Examples of RKHS . . . . . . . . . . . . . . . . 170
5.9 Wavelet Smoothing . . . . . . . . . . . . . . . . . . . . . 174
5.9.1 Wavelet Bases and the Wavelet Transform . . . 176
Adaptive Wavelet Filtering . . . . . . . . . . . . 179
5.9.2
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 181
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Appendix: Computational Considerations for Splines . . . . . . 186
Appendix: B-splines . . . . . . . . . . . . . . . . . . . . . 186
. . . . . 189
Appendix: Computations for Smoothing Splines

Regularization and Reproducing Kernel Hilbert Spaces
5.8.1
5.8.2

5.6
5.7 Multidimensional Splines
5.8

xvi

Contents

6 Kernel Smoothing Methods

6.2
6.3
6.4

6.1 One-Dimensional Kernel Smoothers

191
. . . . . . . . . . . . 192
Local Linear Regression . . . . . . . . . . . . . . 194
6.1.1
Local Polynomial Regression . . . . . . . . . . . 197
6.1.2
Selecting the Width of the Kernel
. . . . . . . . . . . . . 198
Local Regression in IRp . . . . . . . . . . . . . . . . . . . 200
Structured Local Regression Models in IRp
. . . . . . . . 201
Structured Kernels . . . . . . . . . . . . . . . . . 203
6.4.1
Structured Regression Functions . . . . . . . . . 203
6.4.2
. . . . . . . . . . . . 205
Local Likelihood and Other Models
6.5
6.6 Kernel Density Estimation and Classiﬁcation . . . . . . . 208
Kernel Density Estimation . . . . . . . . . . . . 208
Kernel Density Classiﬁcation . . . . . . . . . . . 210
The Naive Bayes Classiﬁer . . . . . . . . . . . . 210
6.7
. . . . . . . . . . . . 212
6.8 Mixture Models for Density Estimation and Classiﬁcation 214
6.9
Computational Considerations . . . . . . . . . . . . . . . 216
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 216
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

6.6.1
6.6.2
6.6.3
Radial Basis Functions and Kernels

7 Model Assessment and Selection

7.1
7.2
7.3

219
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 219
Bias, Variance and Model Complexity . . . . . . . . . . . 219
The Bias–Variance Decomposition . . . . . . . . . . . . . 223
Example: Bias–Variance Tradeoﬀ . . . . . . . . 226
7.3.1
. . . . . . . . . . . 228
7.4 Optimism of the Training Error Rate
Estimates of In-Sample Prediction Error . . . . . . . . . . 230
7.5
The Eﬀective Number of Parameters . . . . . . . . . . . . 232
7.6
7.7
The Bayesian Approach and BIC . . . . . . . . . . . . . . 233
7.8 Minimum Description Length . . . . . . . . . . . . . . . . 235
Vapnik–Chervonenkis Dimension . . . . . . . . . . . . . . 237
7.9
Example (Continued) . . . . . . . . . . . . . . . 239
7.9.1
7.10 Cross-Validation . . . . . . . . . . . . . . . . . . . . . . . 241
7.10.1 K-Fold Cross-Validation . . . . . . . . . . . . . 241
7.10.2

The Wrong and Right Way
to Do Cross-validation . . . . . . . . . . . . . . . 245
7.10.3 Does Cross-Validation Really Work? . . . . . . . 247
. . . . . . . . . . . . . . . . . . . . . 249
Example (Continued) . . . . . . . . . . . . . . . 252
7.12 Conditional or Expected Test Error? . . . . . . . . . . . . 254
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 257
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

7.11 Bootstrap Methods

7.11.1

8 Model Inference and Averaging

261
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 261

8.1

Contents

xvii

8.2

8.5

8.3
8.4

The Bootstrap and Maximum Likelihood Methods . . . . 261
. . . . . . . . . . . . . . 261
8.2.1
A Smoothing Example
Maximum Likelihood Inference . . . . . . . . . . 265
8.2.2
8.2.3
Bootstrap versus Maximum Likelihood . . . . . 267
Bayesian Methods . . . . . . . . . . . . . . . . . . . . . . 267
Relationship Between the Bootstrap
and Bayesian Inference
. . . . . . . . . . . . . . . . . . . 271
The EM Algorithm . . . . . . . . . . . . . . . . . . . . . 272
. . . . . . . . . 272
8.5.1
Two-Component Mixture Model
. . . . . . . . . . 276
8.5.2
The EM Algorithm in General
EM as a Maximization–Maximization Procedure 277
8.5.3
8.6 MCMC for Sampling from the Posterior . . . . . . . . . . 279
Bagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
8.7
Example: Trees with Simulated Data . . . . . . 283
8.7.1
8.8 Model Averaging and Stacking . . . . . . . . . . . . . . . 288
8.9
Stochastic Search: Bumping . . . . . . . . . . . . . . . . . 290
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 292
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

9 Additive Models, Trees, and Related Methods

9.2

295
9.1 Generalized Additive Models . . . . . . . . . . . . . . . . 295
Fitting Additive Models . . . . . . . . . . . . . . 297
9.1.1
Example: Additive Logistic Regression . . . . . 299
9.1.2
9.1.3
Summary . . . . . . . . . . . . . . . . . . . . . . 304
Tree-Based Methods . . . . . . . . . . . . . . . . . . . . . 305
Background . . . . . . . . . . . . . . . . . . . . 305
9.2.1
Regression Trees . . . . . . . . . . . . . . . . . . 307
9.2.2
Classiﬁcation Trees
9.2.3
. . . . . . . . . . . . . . . . 308
. . . . . . . . . . . . . . . . . . . . 310
Other Issues
9.2.4
9.2.5
. . . . . . . . . . . 313
Spam Example (Continued)
PRIM: Bump Hunting . . . . . . . . . . . . . . . . . . . . 317
. . . . . . . . . . . 320
9.3.1
9.4 MARS: Multivariate Adaptive Regression Splines . . . . . 321
Spam Example (Continued)
. . . . . . . . . . . 326
9.4.1
Example (Simulated Data) . . . . . . . . . . . . 327
9.4.2
9.4.3
. . . . . . . . . . . . . . . . . . . . 328
Other Issues
9.5
Hierarchical Mixtures of Experts . . . . . . . . . . . . . . 329
9.6 Missing Data . . . . . . . . . . . . . . . . . . . . . . . . . 332
9.7
Computational Considerations . . . . . . . . . . . . . . . 334
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 334
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

Spam Example (Continued)

9.3

10 Boosting and Additive Trees

337
10.1 Boosting Methods . . . . . . . . . . . . . . . . . . . . . . 337
10.1.1 Outline of This Chapter . . . . . . . . . . . . . . 340

xviii

Contents

10.2 Boosting Fits an Additive Model . . . . . . . . . . . . . . 341
10.3 Forward Stagewise Additive Modeling . . . . . . . . . . . 342
10.4 Exponential Loss and AdaBoost
. . . . . . . . . . . . . . 343
10.5 Why Exponential Loss? . . . . . . . . . . . . . . . . . . . 345
10.6 Loss Functions and Robustness . . . . . . . . . . . . . . . 346
“Oﬀ-the-Shelf” Procedures for Data Mining . . . . . . . . 350
10.7
10.8 Example: Spam Data . . . . . . . . . . . . . . . . . . . . 352
10.9 Boosting Trees . . . . . . . . . . . . . . . . . . . . . . . . 353
10.10 Numerical Optimization via Gradient Boosting . . . . . . 358
10.10.1 Steepest Descent . . . . . . . . . . . . . . . . . . 358
10.10.2 Gradient Boosting . . . . . . . . . . . . . . . . . 359
10.10.3 Implementations of Gradient Boosting . . . . . . 360
10.11 Right-Sized Trees for Boosting . . . . . . . . . . . . . . . 361
10.12 Regularization . . . . . . . . . . . . . . . . . . . . . . . . 364
10.12.1 Shrinkage . . . . . . . . . . . . . . . . . . . . . . 364
10.12.2 Subsampling . . . . . . . . . . . . . . . . . . . . 365
10.13 Interpretation . . . . . . . . . . . . . . . . . . . . . . . . 367
10.13.1 Relative Importance of Predictor Variables . . . 367
10.13.2 Partial Dependence Plots . . . . . . . . . . . . . 369
10.14 Illustrations . . . . . . . . . . . . . . . . . . . . . . . . . . 371
10.14.1 California Housing . . . . . . . . . . . . . . . . . 371
10.14.2 New Zealand Fish . . . . . . . . . . . . . . . . . 375
10.14.3 Demographics Data . . . . . . . . . . . . . . . . 379
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 380
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384

11 Neural Networks

Scaling of the Inputs

389
11.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 389
11.2 Projection Pursuit Regression . . . . . . . . . . . . . . . 389
11.3 Neural Networks . . . . . . . . . . . . . . . . . . . . . . . 392
11.4 Fitting Neural Networks . . . . . . . . . . . . . . . . . . . 395
11.5 Some Issues in Training Neural Networks . . . . . . . . . 397
11.5.1
Starting Values . . . . . . . . . . . . . . . . . . . 397
11.5.2 Overﬁtting . . . . . . . . . . . . . . . . . . . . . 398
. . . . . . . . . . . . . . . 398
11.5.3
11.5.4 Number of Hidden Units and Layers . . . . . . . 400
11.5.5 Multiple Minima . . . . . . . . . . . . . . . . . . 400
11.6 Example: Simulated Data . . . . . . . . . . . . . . . . . . 401
11.7 Example: ZIP Code Data . . . . . . . . . . . . . . . . . . 404
11.8 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . 408
11.9 Bayesian Neural Nets and the NIPS 2003 Challenge . . . 409
Bayes, Boosting and Bagging . . . . . . . . . . . 410
. . . . . . . . . . . . 412
Performance Comparisons
11.10 Computational Considerations . . . . . . . . . . . . . . . 414
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 415

11.9.1
11.9.2

Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415

12 Support Vector Machines and

Contents

xix

417
Flexible Discriminants
12.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 417
12.2 The Support Vector Classiﬁer . . . . . . . . . . . . . . . . 417
12.2.1
Computing the Support Vector Classiﬁer . . . . 420
12.2.2 Mixture Example (Continued) . . . . . . . . . . 421
12.3 Support Vector Machines and Kernels . . . . . . . . . . . 423
Computing the SVM for Classiﬁcation . . . . . . 423
12.3.1
The SVM as a Penalization Method . . . . . . . 426
12.3.2
Function Estimation and Reproducing Kernels . 428
12.3.3
12.3.4
SVMs and the Curse of Dimensionality . . . . . 431
12.3.5 A Path Algorithm for the SVM Classiﬁer . . . . 432
12.3.6
Support Vector Machines for Regression . . . . . 434
12.3.7 Regression and Kernels . . . . . . . . . . . . . . 436
12.3.8 Discussion . . . . . . . . . . . . . . . . . . . . . 438
. . . . . . . . 438
12.4 Generalizing Linear Discriminant Analysis
12.5 Flexible Discriminant Analysis . . . . . . . . . . . . . . . 440
Computing the FDA Estimates . . . . . . . . . . 444
12.6 Penalized Discriminant Analysis . . . . . . . . . . . . . . 446
12.7 Mixture Discriminant Analysis . . . . . . . . . . . . . . . 449
Example: Waveform Data . . . . . . . . . . . . . 451
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 455
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455

12.7.1

12.5.1

13 Prototype Methods and Nearest-Neighbors

13.1
13.2 Prototype Methods

459
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 459
. . . . . . . . . . . . . . . . . . . . . 459
13.2.1 K-means Clustering . . . . . . . . . . . . . . . . 460
Learning Vector Quantization . . . . . . . . . . 462
13.2.2
13.2.3 Gaussian Mixtures . . . . . . . . . . . . . . . . . 463
. . . . . . . . . . . . . . . 463
Example: A Comparative Study . . . . . . . . . 468
Example: k-Nearest-Neighbors
and Image Scene Classiﬁcation . . . . . . . . . . 470
Invariant Metrics and Tangent Distance . . . . . 471
13.4 Adaptive Nearest-Neighbor Methods . . . . . . . . . . . . 475
Example . . . . . . . . . . . . . . . . . . . . . . 478

13.3 k-Nearest-Neighbor Classiﬁers

13.3.1
13.3.2

13.3.3

13.4.1
13.4.2 Global Dimension Reduction

for Nearest-Neighbors . . . . . . . . . . . . . . . 479
13.5 Computational Considerations . . . . . . . . . . . . . . . 480
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 481
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

xx

Contents

14 Unsupervised Learning

Proximity Matrices

14.1
14.2 Association Rules

485
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 485
. . . . . . . . . . . . . . . . . . . . . . 487
14.2.1 Market Basket Analysis . . . . . . . . . . . . . . 488
The Apriori Algorithm . . . . . . . . . . . . . . 489
14.2.2
Example: Market Basket Analysis . . . . . . . . 492
14.2.3
14.2.4 Unsupervised as Supervised Learning . . . . . . 495
14.2.5 Generalized Association Rules
. . . . . . . . . . 497
Choice of Supervised Learning Method . . . . . 499
14.2.6
Example: Market Basket Analysis (Continued) . 499
14.2.7
14.3 Cluster Analysis . . . . . . . . . . . . . . . . . . . . . . . 501
. . . . . . . . . . . . . . . . 503
14.3.1
14.3.2 Dissimilarities Based on Attributes
. . . . . . . 503
14.3.3 Object Dissimilarity . . . . . . . . . . . . . . . . 505
Clustering Algorithms . . . . . . . . . . . . . . . 507
14.3.4
14.3.5
. . . . . . . . . . . . 507
Combinatorial Algorithms
14.3.6 K-means . . . . . . . . . . . . . . . . . . . . . . 509
14.3.7 Gaussian Mixtures as Soft K-means Clustering . 510
14.3.8
Example: Human Tumor Microarray Data . . . 512
14.3.9 Vector Quantization . . . . . . . . . . . . . . . . 514
14.3.10 K-medoids . . . . . . . . . . . . . . . . . . . . . 515
. . . . . . . . . . . . . . . . . . 518
14.3.11 Practical Issues
14.3.12 Hierarchical Clustering . . . . . . . . . . . . . . 520
14.4 Self-Organizing Maps
. . . . . . . . . . . . . . . . . . . . 528
14.5 Principal Components, Curves and Surfaces . . . . . . . . 534
Principal Components . . . . . . . . . . . . . . . 534
14.5.1
Principal Curves and Surfaces
. . . . . . . . . . 541
14.5.2
14.5.3
Spectral Clustering . . . . . . . . . . . . . . . . 544
14.5.4 Kernel Principal Components . . . . . . . . . . . 547
Sparse Principal Components . . . . . . . . . . . 550
14.5.5
14.6 Non-negative Matrix Factorization . . . . . . . . . . . . . 553
14.6.1 Archetypal Analysis . . . . . . . . . . . . . . . . 554
Independent Component Analysis
. . . . . . . . . . . . 557
and Exploratory Projection Pursuit
. . . . . . 558
Latent Variables and Factor Analysis
14.7.1
Independent Component Analysis . . . . . . . . 560
14.7.2
14.7.3
Exploratory Projection Pursuit . . . . . . . . . . 565
14.7.4 A Direct Approach to ICA . . . . . . . . . . . . 565
14.8 Multidimensional Scaling . . . . . . . . . . . . . . . . . . 570
14.9 Nonlinear Dimension Reduction

14.7

and Local Multidimensional Scaling . . . . . . . . . . . . 572
14.10 The Google PageRank Algorithm . . . . . . . . . . . . . 576
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 578
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579

Contents

xxi

15 Random Forests

587
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 587
15.1
15.2 Deﬁnition of Random Forests . . . . . . . . . . . . . . . . 587
. . . . . . . . . . . . . . . . . 592
15.3 Details of Random Forests
15.3.1 Out of Bag Samples . . . . . . . . . . . . . . . . 592
15.3.2 Variable Importance . . . . . . . . . . . . . . . . 593
15.3.3
. . . . . . . . . . . . . . . . . . 595
15.3.4 Random Forests and Overﬁtting . . . . . . . . . 596
15.4 Analysis of Random Forests . . . . . . . . . . . . . . . . . 597
15.4.1 Variance and the De-Correlation Eﬀect . . . . . 597
Bias . . . . . . . . . . . . . . . . . . . . . . . . . 600
15.4.2
. . . . . . . . . . . 601
15.4.3 Adaptive Nearest Neighbors
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 602
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603

Proximity Plots

16 Ensemble Learning

605
16.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 605
16.2 Boosting and Regularization Paths . . . . . . . . . . . . . 607
Penalized Regression . . . . . . . . . . . . . . . 607
16.2.1
16.2.2
The “Bet on Sparsity” Principle . . . . . . . . . 610
16.2.3 Regularization Paths, Over-ﬁtting and Margins . 613
16.3 Learning Ensembles . . . . . . . . . . . . . . . . . . . . . 616
Learning a Good Ensemble . . . . . . . . . . . . 617
. . . . . . . . . . . . . . . . . . 622
Bibliographic Notes . . . . . . . . . . . . . . . . . . . . . . . . . 623
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624

16.3.1
16.3.2 Rule Ensembles

17 Undirected Graphical Models

625
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 625
. . . . . . . . . . . 627
. 630

17.1
17.2 Markov Graphs and Their Properties
17.3 Undirected Graphical Models for Continuous Variables
Estimation of the Parameters
when the Graph Structure is Known . . . . . . . 631
Estimation of the Graph Structure . . . . . . . . 635
. . . 638

17.4 Undirected Graphical Models for Discrete Variables

17.3.2

17.3.1

17.4.1

Estimation of the Parameters
when the Graph Structure is Known . . . . . . . 639
. . . . . . . . . . . . . . . . . . . 641
Estimation of the Graph Structure . . . . . . . . 642
. . . . . . . . . 643
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645

17.4.2 Hidden Nodes
17.4.3
17.4.4 Restricted Boltzmann Machines

18 High-Dimensional Problems: p

649
≫
18.1 When p is Much Bigger than N . . . . . . . . . . . . . . 649

N

xxii

Contents

18.2 Diagonal Linear Discriminant Analysis

and Nearest Shrunken Centroids . . . . . . . . . . . . . . 651
18.3 Linear Classiﬁers with Quadratic Regularization . . . . . 654
18.3.1 Regularized Discriminant Analysis . . . . . . . . 656
18.3.2

Logistic Regression
with Quadratic Regularization . . . . . . . . . . 657
The Support Vector Classiﬁer
. . . . . . . . . . 657
Feature Selection . . . . . . . . . . . . . . . . . . 658
N . . . . . 659
Computational Shortcuts When p
18.4 Linear Classiﬁers with L1 Regularization . . . . . . . . . 661

18.3.3
18.3.4
18.3.5

≫

18.4.1 Application of Lasso

to Protein Mass Spectroscopy . . . . . . . . . . 664
The Fused Lasso for Functional Data . . . . . . 666
18.5 Classiﬁcation When Features are Unavailable . . . . . . . 668

18.4.2

18.5.1

18.5.2

18.5.3

Example: String Kernels
and Protein Classiﬁcation . . . . . . . . . . . . . 668
Classiﬁcation and Other Models Using
Inner-Product Kernels and Pairwise Distances . 670
Example: Abstracts Classiﬁcation . . . . . . . . 672

18.6 High-Dimensional Regression:

. . . . . . . . . . . . . 674
Supervised Principal Components
18.6.1
Connection to Latent-Variable Modeling . . . . 678
18.6.2 Relationship with Partial Least Squares . . . . . 680
Pre-Conditioning for Feature Selection . . . . . 681
18.6.3
18.7 Feature Assessment and the Multiple-Testing Problem . . 683
The False Discovery Rate . . . . . . . . . . . . . 687
18.7.1
690
18.7.2 Asymmetric Cutpoints and the SAM Procedure
18.7.3 A Bayesian Interpretation of the FDR . . . . . . 692
18.8 Bibliographic Notes
. . . . . . . . . . . . . . . . . . . . . 693
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694

References

Author Index

Index

699

729

737

1
Introduction

This is page 1
Printer: Opaque this

Statistical learning plays a key role in many areas of science, ﬁnance and
industry. Here are some examples of learning problems:

•

•

•

•

•

Predict whether a patient, hospitalized due to a heart attack, will
have a second heart attack. The prediction is to be based on demo-
graphic, diet and clinical measurements for that patient.

Predict the price of a stock in 6 months from now, on the basis of
company performance measures and economic data.

Identify the numbers in a handwritten ZIP code, from a digitized
image.

Estimate the amount of glucose in the blood of a diabetic person,
from the infrared absorption spectrum of that person’s blood.

Identify the risk factors for prostate cancer, based on clinical and
demographic variables.

The science of learning plays a key role in the ﬁelds of statistics, data
mining and artiﬁcial intelligence, intersecting with areas of engineering and
other disciplines.

This book is about learning from data. In a typical scenario, we have
an outcome measurement, usually quantitative (such as a stock price) or
categorical (such as heart attack/no heart attack), that we wish to predict
based on a set of features (such as diet and clinical measurements). We
have a training set of data, in which we observe the outcome and feature

2

1. Introduction

TABLE 1.1. Average percentage of words or characters in an email message
equal to the indicated word or character. We have chosen the words and characters
showing the largest diﬀerence between spam and email.

george

you your

hp free

hpl

!

our

re

spam
email

0.00 2.26 1.38 0.02 0.52 0.01 0.51 0.51 0.13 0.01
1.27 1.27 0.44 0.90 0.07 0.43 0.11 0.18 0.42 0.29

edu remove
0.28
0.01

measurements for a set of objects (such as people). Using this data we build
a prediction model, or learner, which will enable us to predict the outcome
for new unseen objects. A good learner is one that accurately predicts such
an outcome.

The examples above describe what is called the supervised learning prob-
lem. It is called “supervised” because of the presence of the outcome vari-
able to guide the learning process. In the unsupervised learning problem,
we observe only the features and have no measurements of the outcome.
Our task is rather to describe how the data are organized or clustered. We
devote most of this book to supervised learning; the unsupervised problem
is less developed in the literature, and is the focus of Chapter 14.

Here are some examples of real learning problems that are discussed in

this book.

Example 1: Email Spam

The data for this example consists of information from 4601 email mes-
sages, in a study to try to predict whether the email was junk email, or
“spam.” The objective was to design an automatic spam detector that
could ﬁlter out spam before clogging the users’ mailboxes. For all 4601
email messages, the true outcome (email type) email or spam is available,
along with the relative frequencies of 57 of the most commonly occurring
words and punctuation marks in the email message. This is a supervised
learning problem, with the outcome the class variable email/spam. It is also
called a classiﬁcation problem.

Table 1.1 lists the words and characters showing the largest average

diﬀerence between spam and email.

Our learning method has to decide which features to use and how: for

example, we might use a rule such as

if (%george < 0.6) & (%you > 1.5)

then spam
else email.

Another form of a rule might be:

if (0.2

%you

·

0.3

·

−

%george) > 0

then spam
else email.

−1

1 2 3 4

40 50 60 70 80

0.0

0.4

0.8

6.0

7.0

8.0

9.0

1. Introduction

3

4

3

2

1

1
−

0
8

0
7

0
6

0
5

0
4

8
.
0

4
.
0

0
.
0

0
.
9

0
.
8

0
.
7

0
.
6

lpsa

o
o
o
o
oo
oo
o
ooo
o
o
ooo
o
o
o
oo
o
oo
o
oo
o
o
o
o
o
ooo
o
o
ooo
o
o
o
o
o
o
o
oo
o
oo
oo
oo
o
o
o
o
o
oo
oo
o
oo
o
o
o
o
o
oo
oo
o
oo
o
o
o
o
o
o
o
o

o

o

o
o
oo
o
o
o
o
o
o
o
o
o
o
oo
o
o
oo
oo
ooo
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
oo
o
o
oo
ooo
o
o
o
oooo
o
o
o
oo
o
o
o
oo
o
o
o
o
o
oo
o
o
o
o
o
oo
o

o

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
oo
o
o
oo
o
o
o
o
o
o
o
o
o
oooooo
o
o
o
oo
o
o
o
o
oooo
o
oo
o
oo
o
o
o
o
o
oo
o
o
o
o
o
o
ooo
o
o
o
o
o
o
o
o
o

o
o

oo
o

o

o

o
o
o
o

o
o

o
o

o

o
o

o

o

o

o
oo
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o

o
o
o

o

o
o

o
o
o
o
o
oo
o
o
o
o
o
oo
o
o
ooo
o
oo
o
o
oooo
ooo
oo
o
o
o
oo

oooo oo

o
oo

o
o
o

oo

o

o

o

o

o

o

oo o
ooo o
o
o
oo
o
o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
o
o
o
o
o
o
o
o
o
o

o

o

lbph

o

o
o

o

o

o

oo
oo o
o
oo oo o o
o
o
oo o
oo o o
o
o
o
o
oooo o oo o
o
o
o
o
o o
oooo o
o
o
ooo oo
o o
o o
o
oo
o
ooo o oooooooo o
o
o oo
o
oooo o
oo
o
o
o

o

oo

o

o

o

o
o
o

o
o

o

o
o
o
o
oo
o
o o
o
oo
o
o
o
o
o
o
o o
o
oo
o
o o
o
o
o
o
o
o oo
o
o o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o o
o
oo
o
o
o
o
o
o
o
oo
oo
o
o
o
o
o
o

o

o
o
o

o

o
o

o

o
o

o

o

o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
oo
o
o
o
oo
o
o
o
ooo o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o o

o
o

o
o
o

o

o

o

o

age

o

o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o

o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o o
o
o
o o
oo
o
o
o
o
o
o
o o
o
o

o

o

o
o

o
o
o

o
o

o
o
o
o

ooo
o
o
oooo
o
o
o
o
o
o

oooooo

o
o
o
o
o o
o

oo ooo o
o
o
o
oo
o
o
o

o o o
o
o oo
o
o
o
o
o
o
o
o
o
o
o
o
o

o

o

oo
o
o o
o o
o
o
o
oo
o
o
o
o

o
o
o

ooo
o
oo
o
o
o
o

o

o

o
o

o

o
o
o
o

o
o

oooo oooooooooooooooooooooooooooooooooo

o
o
oo
oo
ooo
o
oooooooooooooo
oooooo
o
ooooooo

o
o
o
oooo
o
o
o
o
o
o
o o
o
o
o
oo oo
oo oo
oooo oo
o
o
o
o ooo o
ooo
oo oo
ooo
oo
o oo
o
oo
o
ooo
o
oo
o
o
o o o o
o
o
o

o
o

o

o
oo
o
ooo oooo oo
oo
ooooo o
o o
o
o
oo
o
o
o ooo o o
oo
o
o
o oo
o
o
oo o o
o
o
o
o
oo
ooo
oo
oo oo ooo
oo
o oo
o o
o
o

o
o

oo
o
o
o

o
oooo o
o
o
oo
o
o o
oo
o o
o
o
oo o oo o
o
o
o
o o
o
o oo
o o
oooo o
o
ooo oo
o o
o
o
oo
o
ooo o oooooooo o
o
o

o
oooooo
o
o
o
o
o
o
o
o
o
oo
o
oo
o
o
o
oo
oooo
ooo

o
o

oo
o
o
o
o
o
o

o
o
o o
o
oo
o
o
o
o o o
o
o
o
o
o
ooo
ooo
o
o
o
o
o
o
o
o
o

o

o

o

o

o

o
o
o
o
o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
oooo oooooooo
oo
o
ooo
o
oo
oooo
ooo
o
o
oo
o

o
o

o
oo
o

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
oo oo
o
o oo
oo
o
o
o
o o o
o
o
o
o
oo oo
o
o
o
o
o
o
o
o
o o

o
o
oo

o

o

o
o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
ooo oooo oo
o
o
o
o
o
oo
o
o
o
o
o
o oo
o
o
o o
o
oo
o
o o
o

o
o
o
o

o

o

o

o
o

o

o

o

o

o

o
o

o
o
o
o

o

o

o

o
o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
ooo
o
o
o
o o
oo
o
o
o
oo
o
o
o
o
o
o o
o
o
o o
oo
o
oo

o

o
o

o
o

o
o

o
o
o
o

o

o

o

o

o
o
o

o
o

o

o

o

o
o

o

o

o

o

o

o

o

ooo
oo
ooooooooo
oooo
o
ooo
o
o
ooo
o
oo
ooooo
o
ooo
o
ooo
o
o
ooo
o

oooooo

oo ooo o
oo
o
ooo
o
o
o
o
o
o
o ooo
o
o
oo
o ooo
o oo
o
o
o o
o
oo
o
o
oo
o
o
ooo
o
o
o
o
o
o
o

o

o

o o o
o
o oo
oo
o
o
oo o
oo
o o o
o o
oo
o
o
o
o
oo
ooo
o
o
oo
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o

o
o

o

o

o

oo
o o
o o
o
o
o o
o o
o
o
o
o
o
oo o
oo o o
o
o
o
o o o
o
o
o
o
o
o o
o o
o
o
o oo
o
o
o o
o
ooo
o

o
o
o
oo
o
o
o
oooooo
o
oo
o
oooo
o oooooooo
oo

o
o

o
o
o
oo
o
o
o
o
o
o
oo
o
oo
o oo
o
oo
o
o
oo
o
o o o
o
o
o
o

o

o

o
oo
o
ooo oooo oo
o
o
oo
o
oo
o
oo
o oo
o
o
o
o
o
o

o
o

o
o

o
o
o
o

o

o
o
o
o
o
o
o
o o
o
ooo o
o
o
o
o
ooo
oo
o
o
o
oo

o
o
o

o

o

o
o
o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
oo
o
o
o
oo
o
o
o
o
o
oo
o
o
ooooooo
ooo
oo
o
o
o
oo
oooo
o
o oooooooo
oo
o
o
o
oo

o

o

o

o

o

o

o
o
o

o
o
o
o
o
o
o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
oo
o
o
oo
o
o
o
o
o
o
o
o
ooo
oo
o
o
o
o
oo
o
oo
o
o
o
o
oo
o
o oo
oo
o
o o o
o
o
o
o
o
oo

o
o
o

o
o

o

o
o
o
o

o

o

o

o

o
o
o

o

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o oo
o
o
o
o
oo
o
o oo
o
o
o
o
ooo oooo oo
oo
o
oo
o
o
o
o
oo

o
o

o

o

o
o

o

o

o
o

o

o

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
oo
o
o
oo
o
o
ooo o
o
o
oo
o
o o
o
oo
o
ooo
o
o
o
o
o
o
o
o
o
o

o
o
o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
oooooo
o
o
ooo
o
o
o
o
o
o
o
o

o
o

ooo
o
oo
o
oo
o
o
o
o
o
o
o
o
o
o
ooo

o
oo
o
o
o
oo
o
o
oo
o
ooo
ooo

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
ooo
o
o
o
oo
o
oo
o
oo
ooo
ooo
o
o

o

o
o

o
o

o

o

o

o

o

o
o
o
o

o
o

o

o

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o

o

o

o

o

o

o

o
o
oo
o
o
o

o
o
o
o
o
oo
o
o
oo
o
o
o
o o o
o
o
o
o
oo
o
o

o

o

o

o
o
o
o
ooo
o
o
o
o
o

o

o

o
o

o
o

o

o
o

o
o

o

o
o

o

o
o
o
o
o
o
o

o
o
o
o
o
o
o
o
o
o
o
o
o
ooo
o
o
o
o
o
o
o
o

o
o
o
o

o

o

o
o
o

o
o
oo
ooo
oo
o
oooooo
o
oooooooooooooo
ooooooo

ooooooooooooooooooooooooooooooooo

o
oooo

o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
ooo
o
o
ooo
o
o
o
o
o
o
oo
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
o
o
o
o
o
o
o

o
o
o
o
o
o
ooo
o
oo
o
oo
oo
ooo

o
oo
o
o
o
o
o
o
oo
o
oooooo
oo
o
oooo
o
ooooooooo

o

o

o
o
o
o
o
o
oo
o
ooooooooo
oo
o
ooo
o
o
ooo
o
o
o
o

o

o

o

o

o

o

o

oooooo
o
ooo
o
o
o
oo
o
o
o
o

o
o
o
o
o
oo
o
o
oo
oo
o
o
o
o
o
o
o
oo
o
o

o
o
o
o
o
o
oo
o
o
o
o
o

o
o
o oo
o
o o
o
o
o
o
o
o
o
o
o
o

o

o
oo
o
o
o
o
o
o
o o
oooo o
oo
o
ooo
o
ooooooooo

o

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o

o
o
o
o
o
o
o

o

o

o
o
o
o
o
o
o

o

o

o
o
o
o
o

o

o

o
o

o
o
o
o
o
o
o
o
o
o
o
o
o o
o
oooo oo
o
o
o
o
oo
oo
o
ooo
o
ooooooooo
o
o
o
o o

o
o
o
o
o
o
o
o

o

o
o
o
o
o

o
o

o

o
o

o

o

o
o
o
o
o
o
oooooo
oo
oo
o
oooo
o
ooooooooo
o
o
oo

gleason

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o

o

o

o

o
o o
o
o
o
oo
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o

o

o
o

o

o
o o
o
o
o
o
o
o
oo
ooo
o
o
o
o
o ooo
o
oo
ooo oo
o
ooooooo oo
o
oo
o
o
oooo
ooo
ooooooo
o
oo
o

o

o
o
o
o
o
o
o
o

o
o

o

o
o

o
o
o
o
o
o

o
o

o

o
o
o

o
o
o
o
o
o
o
o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o oo
o
o
o
o
o
o
oo
o
o
o
o
o o
o
oo
o
oo
o
o
o
o
o
o
oo
o
o
o
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
o

o
oo
o
o
o
o
o
o
oo
o
oooooo
oo
o
oooo
o
ooooooooo

pgg45

o
o
o
o
o

o
o
o
o

o

o
o
o
o
o

o

o

o
o
o

o

o

o

o
o

o
o

o
o
o

o

o
o
o

o

o
o
o
o
o

5

4

3

2

1

0

5
4

.

5
3

.

5
2

.

2

1

0

1
−

3

2

1

0

1
−

0
0
1

0
6

0
2

0

0 1 2 3 4 5

2.5

3.5

4.5

−1

0

1

2

−1 0

1

2

3

0 20

60

100

FIGURE 1.1. Scatterplot matrix of the prostate cancer data. The ﬁrst row shows
the response against each of the predictors in turn. Two of the predictors, svi and
gleason, are categorical.

For this problem not all errors are equal; we want to avoid ﬁltering out
good email, while letting spam get through is not desirable but less serious
in its consequences. We discuss a number of diﬀerent methods for tackling
this learning problem in the book.

Example 2: Prostate Cancer

The data for this example, displayed in Figure 1.11, come from a study
by Stamey et al. (1989) that examined the correlation between the level of

1There was an error in these data in the ﬁrst edition of this book. Subject 32 had
a value of 6.1 for lweight, which translates to a 449 gm prostate! The correct value is
44.9 gm. We are grateful to Prof. Stephen W. Link for alerting us to this error.

4

1. Introduction

FIGURE 1.2. Examples of handwritten digits from U.S. postal envelopes.

prostate speciﬁc antigen (PSA) and a number of clinical measures, in 97
men who were about to receive a radical prostatectomy.

The goal is to predict the log of PSA (lpsa) from a number of measure-
ments including log cancer volume (lcavol), log prostate weight lweight,
age, log of benign prostatic hyperplasia amount lbph, seminal vesicle in-
vasion svi, log of capsular penetration lcp, Gleason score gleason, and
percent of Gleason scores 4 or 5 pgg45. Figure 1.1 is a scatterplot matrix
of the variables. Some correlations with lpsa are evident, but a good pre-
dictive model is diﬃcult to construct by eye.

This is a supervised learning problem, known as a regression problem,

because the outcome measurement is quantitative.

Example 3: Handwritten Digit Recognition

The data from this example come from the handwritten ZIP codes on
envelopes from U.S. postal mail. Each image is a segment from a ﬁve digit
ZIP code, isolating a single digit. The images are 16
16 eight-bit grayscale
maps, with each pixel ranging in intensity from 0 to 255. Some sample
images are shown in Figure 1.2.

×

The images have been normalized to have approximately the same size
and orientation. The task is to predict, from the 16
16 matrix of pixel
intensities, the identity of each image (0, 1, . . . , 9) quickly and accurately. If
it is accurate enough, the resulting algorithm would be used as part of an
automatic sorting procedure for envelopes. This is a classiﬁcation problem
for which the error rate needs to be kept very low to avoid misdirection of

×

1. Introduction

5

mail. In order to achieve this low error rate, some objects can be assigned
to a “don’t know” category, and sorted instead by hand.

Example 4: DNA Expression Microarrays

DNA stands for deoxyribonucleic acid, and is the basic material that makes
up human chromosomes. DNA microarrays measure the expression of a
gene in a cell by measuring the amount of mRNA (messenger ribonucleic
acid) present for that gene. Microarrays are considered a breakthrough
technology in biology, facilitating the quantitative study of thousands of
genes simultaneously from a single sample of cells.

Here is how a DNA microarray works. The nucleotide sequences for a few
thousand genes are printed on a glass slide. A target sample and a reference
sample are labeled with red and green dyes, and each are hybridized with
the DNA on the slide. Through ﬂuoroscopy, the log (red/green) intensities
of RNA hybridizing at each site is measured. The result is a few thousand
numbers, typically ranging from say
6 to 6, measuring the expression level
−
of each gene in the target relative to the reference sample. Positive values
indicate higher expression in the target versus the reference, and vice versa
for negative values.

A gene expression dataset collects together the expression values from a
series of DNA microarray experiments, with each column representing an
experiment. There are therefore several thousand rows representing individ-
ual genes, and tens of columns representing samples: in the particular ex-
ample of Figure 1.3 there are 6830 genes (rows) and 64 samples (columns),
although for clarity only a random sample of 100 rows are shown. The ﬁg-
ure displays the data set as a heat map, ranging from green (negative) to
red (positive). The samples are 64 cancer tumors from diﬀerent patients.

The challenge here is to understand how the genes and samples are or-

ganized. Typical questions include the following:

(a) which samples are most similar to each other, in terms of their expres-

sion proﬁles across genes?

(b) which genes are most similar to each other, in terms of their expression

proﬁles across samples?

(c) do certain genes show very high (or low) expression for certain cancer

samples?

We could view this task as a regression problem, with two categorical
predictor variables—genes and samples—with the response variable being
the level of expression. However, it is probably more useful to view it as
unsupervised learning problem. For example, for question (a) above, we
think of the samples as points in 6830–dimensional space, which we want
to cluster together in some way.

6

1. Introduction

SIDW299104
SIDW380102
SID73161
GNAL
H.sapiensmRNA
SID325394
RASGTPASE
SID207172
ESTs
SIDW377402
HumanmRNA
SIDW469884
ESTs
SID471915
MYBPROTO
ESTsChr.1
SID377451
DNAPOLYMER
SID375812
SIDW31489
SID167117
SIDW470459
SIDW487261
Homosapiens
SIDW376586
Chr
MITOCHONDRIAL60
SID47116
ESTsChr.6
SIDW296310
SID488017
SID305167
ESTsChr.3
SID127504
SID289414
PTPRC
SIDW298203
SIDW310141
SIDW376928
ESTsCh31
SID114241
SID377419
SID297117
SIDW201620
SIDW279664
SIDW510534
HLACLASSI
SIDW203464
SID239012
SIDW205716
SIDW376776
HYPOTHETICAL
WASWiskott
SIDW321854
ESTsChr.15
SIDW376394
SID280066
ESTsChr.5
SIDW488221
SID46536
SIDW257915
ESTsChr.2
SIDW322806
SID200394
ESTsChr.15
SID284853
SID485148
SID297905
ESTs
SIDW486740
SMALLNUC
ESTs
SIDW366311
SIDW357197
SID52979
ESTs
SID43609
SIDW416621
ERLUMEN
TUPLE1TUP1
SIDW428642
SID381079
SIDW298052
SIDW417270
SIDW362471
ESTsChr.15
SIDW321925
SID380265
SIDW308182
SID381508
SID377133
SIDW365099
ESTsChr.10
SIDW325120
SID360097
SID375990
SIDW128368
SID301902
SID31984
SID42354

L
A
N
E
R

T
S
A
E
R
B

A
M
O
N
A
L
E
M

A
M
O
N
A
L
E
M

o
r
p
e
r
-

D
7
F
C
M

N
O
L
O
C

N
O
L
O
C

o
r
p
e
r
-

B
2
6
5
K

N
O
L
O
C

C
L
C
S
N

T
S
A
E
R
B

L
A
N
E
R

I

A
M
E
K
U
E
L

A
M
O
N
A
L
E
M

S
N
C

S
N
C

L
A
N
E
R

o
r
p
e
r
-

A
7
F
C
M

C
L
C
S
N

o
r
p
e
r
-

A
2
6
5
K

N
O
L
O
C

S
N
C

C
L
C
S
N

C
L
C
S
N

S
N
C

T
S
A
E
R
B

I

N
A
R
A
V
O

I

A
M
E
K
U
E
L

I

A
M
E
K
U
E
L

A
M
O
N
A
L
E
M

A
M
O
N
A
L
E
M

I

N
A
R
A
V
O

I

N
A
R
A
V
O

C
L
C
S
N

L
A
N
E
R

T
S
A
E
R
B

A
M
O
N
A
L
E
M

I

N
A
R
A
V
O

I

N
A
R
A
V
O

C
L
C
S
N

L
A
N
E
R

T
S
A
E
R
B

I

A
M
E
K
U
E
L

A
M
O
N
A
L
E
M

N
O
L
O
C

T
S
A
E
R
B

I

A
M
E
K
U
E
L

S
N
C

N
O
L
O
C

A
M
O
N
A
L
E
M

C
L
C
S
N

E
T
A
T
S
O
R
P

C
L
C
S
N

L
A
N
E
R

L
A
N
E
R

C
L
C
S
N

L
A
N
E
R

I

N
A
R
A
V
O

I

A
M
E
K
U
E
L

E
T
A
T
S
O
R
P

N
O
L
O
C

T
S
A
E
R
B

L
A
N
E
R

N
W
O
N
K
N
U

FIGURE 1.3. DNA microarray data: expression matrix of 6830 genes (rows)
and 64 samples (columns), for the human tumor data. Only a random sample
of 100 rows are shown. The display is a heat map, ranging from bright green
(negative, under expressed) to bright red (positive, over expressed). Missing values
are gray. The rows and columns are displayed in a randomly chosen order.

1. Introduction

7

Who Should Read this Book

This book is designed for researchers and students in a broad variety of
ﬁelds: statistics, artiﬁcial intelligence, engineering, ﬁnance and others. We
expect that the reader will have had at least one elementary course in
statistics, covering basic topics including linear regression.

We have not attempted to write a comprehensive catalog of learning
methods, but rather to describe some of the most important techniques.
Equally notable, we describe the underlying concepts and considerations
by which a researcher can judge a learning method. We have tried to write
this book in an intuitive fashion, emphasizing concepts rather than math-
ematical details.

As statisticians, our exposition will naturally reﬂect our backgrounds and
areas of expertise. However in the past eight years we have been attending
conferences in neural networks, data mining and machine learning, and our
thinking has been heavily inﬂuenced by these exciting ﬁelds. This inﬂuence
is evident in our current research, and in this book.

How This Book is Organized

Our view is that one must understand simple methods before trying to
grasp more complex ones. Hence, after giving an overview of the supervis-
ing learning problem in Chapter 2, we discuss linear methods for regression
and classiﬁcation in Chapters 3 and 4. In Chapter 5 we describe splines,
wavelets and regularization/penalization methods for a single predictor,
while Chapter 6 covers kernel methods and local regression. Both of these
sets of methods are important building blocks for high-dimensional learn-
ing techniques. Model assessment and selection is the topic of Chapter 7,
covering the concepts of bias and variance, overﬁtting and methods such as
cross-validation for choosing models. Chapter 8 discusses model inference
and averaging, including an overview of maximum likelihood, Bayesian in-
ference and the bootstrap, the EM algorithm, Gibbs sampling and bagging,
A related procedure called boosting is the focus of Chapter 10.

In Chapters 9–13 we describe a series of structured methods for su-
pervised learning, with Chapters 9 and 11 covering regression and Chap-
ters 12 and 13 focusing on classiﬁcation. Chapter 14 describes methods for
unsupervised learning. Two recently proposed techniques, random forests
and ensemble learning, are discussed in Chapters 15 and 16. We describe
undirected graphical models in Chapter 17 and ﬁnally we study high-
dimensional problems in Chapter 18.

At the end of each chapter we discuss computational considerations im-
portant for data mining applications, including how the computations scale
with the number of observations and predictors. Each chapter ends with
Bibliographic Notes giving background references for the material.

8

1. Introduction

We recommend that Chapters 1–4 be ﬁrst read in sequence. Chapter 7
should also be considered mandatory, as it covers central concepts that
pertain to all learning methods. With this in mind, the rest of the book
can be read sequentially, or sampled, depending on the reader’s interest.

The symbol

indicates a technically diﬃcult section, one that can

be skipped without interrupting the ﬂow of the discussion.

Book Website

The website for this book is located at

http://www-stat.stanford.edu/ElemStatLearn

It contains a number of resources, including many of the datasets used in
this book.

Note for Instructors

We have successively used the ﬁrst edition of this book as the basis for a
two-quarter course, and with the additional materials in this second edition,
it could even be used for a three-quarter sequence. Exercises are provided at
the end of each chapter. It is important for students to have access to good
software tools for these topics. We used the R and S-PLUS programming
languages in our courses.

2
Overview of Supervised Learning

This is page 9
Printer: Opaque this

2.1

Introduction

The ﬁrst three examples described in Chapter 1 have several components
in common. For each there is a set of variables that might be denoted as
inputs, which are measured or preset. These have some inﬂuence on one or
more outputs. For each example the goal is to use the inputs to predict the
values of the outputs. This exercise is called supervised learning.

We have used the more modern language of machine learning. In the
statistical literature the inputs are often called the predictors, a term we
will use interchangeably with inputs, and more classically the independent
variables. In the pattern recognition literature the term features is preferred,
which we use as well. The outputs are called the responses, or classically
the dependent variables.

2.2 Variable Types and Terminology

The outputs vary in nature among the examples. In the glucose prediction
example, the output is a quantitative measurement, where some measure-
ments are bigger than others, and measurements close in value are close
in nature. In the famous Iris discrimination example due to R. A. Fisher,
the output is qualitative (species of Iris) and assumes values in a ﬁnite set
. In the handwritten digit example
}
. In both of
0, 1, . . . , 9
}
{

Virginica, Setosa and Versicolor
G
{
the output is one of 10 diﬀerent digit classes:

=

=

G

10

2. Overview of Supervised Learning

these there is no explicit ordering in the classes, and in fact often descrip-
tive labels rather than numbers are used to denote the classes. Qualitative
variables are also referred to as categorical or discrete variables as well as
factors.

For both types of outputs it makes sense to think of using the inputs to
predict the output. Given some speciﬁc atmospheric measurements today
and yesterday, we want to predict the ozone level tomorrow. Given the
grayscale values for the pixels of the digitized image of the handwritten
digit, we want to predict its class label.

This distinction in output type has led to a naming convention for the
prediction tasks: regression when we predict quantitative outputs, and clas-
siﬁcation when we predict qualitative outputs. We will see that these two
tasks have a lot in common, and in particular both can be viewed as a task
in function approximation.

Inputs also vary in measurement type; we can have some of each of qual-
itative and quantitative input variables. These have also led to distinctions
in the types of methods that are used for prediction: some methods are
deﬁned most naturally for quantitative inputs, some most naturally for
qualitative and some for both.

A third variable type is ordered categorical, such as small, medium and
large, where there is an ordering between the values, but no metric notion
is appropriate (the diﬀerence between medium and small need not be the
same as that between large and medium). These are discussed further in
Chapter 4.

Qualitative variables are typically represented numerically by codes. The
easiest case is when there are only two classes or categories, such as “suc-
cess” or “failure,” “survived” or “died.” These are often represented by a
single binary digit or bit as 0 or 1, or else by
1 and 1. For reasons that will
become apparent, such numeric codes are sometimes referred to as targets.
When there are more than two categories, several alternatives are available.
The most useful and commonly used coding is via dummy variables. Here a
K-level qualitative variable is represented by a vector of K binary variables
or bits, only one of which is “on” at a time. Although more compact coding
schemes are possible, dummy variables are symmetric in the levels of the
factor.

−

We will typically denote an input variable by the symbol X. If X is
a vector, its components can be accessed by subscripts Xj. Quantitative
outputs will be denoted by Y , and qualitative outputs by G (for group).
We use uppercase letters such as X, Y or G when referring to the generic
aspects of a variable. Observed values are written in lowercase; hence the
ith observed value of X is written as xi (where xi is again a scalar or
vector). Matrices are represented by bold uppercase letters; for example, a
set of N input p-vectors xi, i = 1, . . . , N would be represented by the N
p
×
matrix X. In general, vectors will not be bold, except when they have N
components; this convention distinguishes a p-vector of inputs xi for the

2.3 Least Squares and Nearest Neighbors

11

ith observation from the N -vector xj consisting of all the observations on
variable Xj. Since all vectors are assumed to be column vectors, the ith
row of X is xT

i , the vector transpose of xi.

For the moment we can loosely state the learning task as follows: given
the value of an input vector X, make a good prediction of the output Y,
denoted by ˆY (pronounced “y-hat”). If Y takes values in IR then so should
ˆY ; likewise for categorical outputs, ˆG should take values in the same set
associated with G.

G

For a two-class G, one approach is to denote the binary coded target
as Y , and then treat it as a quantitative output. The predictions ˆY will
typically lie in [0, 1], and we can assign to ˆG the class label according to
whether ˆy > 0.5. This approach generalizes to K-level qualitative outputs
as well.

We need data to construct prediction rules, often a lot of it. We thus
suppose we have available a set of measurements (xi, yi) or (xi, gi), i =
1, . . . , N , known as the training data, with which to construct our prediction
rule.

2.3 Two Simple Approaches to Prediction: Least

Squares and Nearest Neighbors

In this section we develop two simple but powerful prediction methods: the
linear model ﬁt by least squares and the k-nearest-neighbor prediction rule.
The linear model makes huge assumptions about structure and yields stable
but possibly inaccurate predictions. The method of k-nearest neighbors
makes very mild structural assumptions: its predictions are often accurate
but can be unstable.

2.3.1 Linear Models and Least Squares

The linear model has been a mainstay of statistics for the past 30 years
and remains one of our most important tools. Given a vector of inputs
X T = (X1, X2, . . . , Xp), we predict the output Y via the model

p

ˆY = ˆβ0 +

Xj ˆβj.

j=1
X

(2.1)

The term ˆβ0 is the intercept, also known as the bias in machine learning.
Often it is convenient to include the constant variable 1 in X, include ˆβ0 in
the vector of coeﬃcients ˆβ, and then write the linear model in vector form
as an inner product

ˆY = X T ˆβ,

(2.2)

12

2. Overview of Supervised Learning

where X T denotes vector or matrix transpose (X being a column vector).
Here we are modeling a single output, so ˆY is a scalar; in general ˆY can be
a K–vector, in which case β would be a p
K matrix of coeﬃcients. In the
(p + 1)-dimensional input–output space, (X, ˆY ) represents a hyperplane.
If the constant is included in X, then the hyperplane includes the origin
and is a subspace; if not, it is an aﬃne set cutting the Y -axis at the point
(0, ˆβ0). From now on we assume that the intercept is included in ˆβ.

×

Viewed as a function over the p-dimensional input space, f (X) = X T β
is linear, and the gradient f ′(X) = β is a vector in input space that points
in the steepest uphill direction.

How do we ﬁt the linear model to a set of training data? There are
many diﬀerent methods, but by far the most popular is the method of
least squares. In this approach, we pick the coeﬃcients β to minimize the
residual sum of squares

N

RSS(β) =

(yi −

xT
i β)2.

(2.3)

i=1
X
RSS(β) is a quadratic function of the parameters, and hence its minimum
always exists, but may not be unique. The solution is easiest to characterize
in matrix notation. We can write

RSS(β) = (y

Xβ)T (y

Xβ),

(2.4)

−
where X is an N
p matrix with each row an input vector, and y is an
N -vector of the outputs in the training set. Diﬀerentiating w.r.t. β we get
the normal equations

−

×

XT (y
If XT X is nonsingular, then the unique solution is given by

Xβ) = 0.

−

ˆβ = (XT X)−1XT y,

(2.5)

(2.6)

ˆβ. At an arbi-
and the ﬁtted value at the ith input xi is ˆyi = ˆy(xi) = xT
i
ˆβ. The entire ﬁtted surface is
trary input x0 the prediction is ˆy(x0) = xT
0
characterized by the p parameters ˆβ. Intuitively, it seems that we do not
need a very large data set to ﬁt such a model.

Let’s look at an example of the linear model in a classiﬁcation context.
Figure 2.1 shows a scatterplot of training data on a pair of inputs X1 and
X2. The data are simulated, and for the present the simulation model is
not important. The output class variable G has the values BLUE or ORANGE,
and is represented as such in the scatterplot. There are 100 points in each
of the two classes. The linear regression model was ﬁt to these data, with
the response Y coded as 0 for BLUE and 1 for ORANGE. The ﬁtted values ˆY
are converted to a ﬁtted class variable ˆG according to the rule

ˆG =

ORANGE

BLUE

(

if ˆY > 0.5,
if ˆY
0.5.

≤

(2.7)

2.3 Least Squares and Nearest Neighbors

13

Linear Regression of 0/1 Response

o

o

o

o

o

o

o

o

o

o
o

o
o

o
o

o
o
o
o

o
o
o
o
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
oo
. . . . . . . .. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
oo
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.. . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

o
o
o
o
o

o
o
o
o

o
o

o
o
o

o
o

o
o
o

o
o

o

o

o

o

o

o

o

o

o

o

FIGURE 2.1. A classiﬁcation example in two dimensions. The classes are coded
as a binary variable (BLUE = 0, ORANGE = 1), and then ﬁt by linear regression.
The line is the decision boundary deﬁned by xT ˆβ = 0.5. The orange shaded region
denotes that part of input space classiﬁed as ORANGE, while the blue region is
classiﬁed as BLUE.

x : xT ˆβ > 0.5
The set of points in IR2 classiﬁed as ORANGE corresponds to
,
}
{
indicated in Figure 2.1, and the two predicted classes are separated by the
x : xT ˆβ = 0.5
, which is linear in this case. We see
decision boundary
}
{
that for these data there are several misclassiﬁcations on both sides of the
decision boundary. Perhaps our linear model is too rigid— or are such errors
unavoidable? Remember that these are errors on the training data itself,
and we have not said where the constructed data came from. Consider the
two possible scenarios:

Scenario 1: The training data in each class were generated from bivariate
Gaussian distributions with uncorrelated components and diﬀerent
means.

Scenario 2: The training data in each class came from a mixture of 10 low-
variance Gaussian distributions, with individual means themselves
distributed as Gaussian.

A mixture of Gaussians is best described in terms of the generative
model. One ﬁrst generates a discrete variable that determines which of

14

2. Overview of Supervised Learning

the component Gaussians to use, and then generates an observation from
the chosen density. In the case of one Gaussian per class, we will see in
Chapter 4 that a linear decision boundary is the best one can do, and that
our estimate is almost optimal. The region of overlap is inevitable, and
future data to be predicted will be plagued by this overlap as well.

In the case of mixtures of tightly clustered Gaussians the story is dif-
ferent. A linear decision boundary is unlikely to be optimal, and in fact is
not. The optimal decision boundary is nonlinear and disjoint, and as such
will be much more diﬃcult to obtain.

We now look at another classiﬁcation and regression procedure that is
in some sense at the opposite end of the spectrum to the linear model, and
far better suited to the second scenario.

2.3.2 Nearest-Neighbor Methods

Nearest-neighbor methods use those observations in the training set
clos-
est in input space to x to form ˆY . Speciﬁcally, the k-nearest neighbor ﬁt
for ˆY is deﬁned as follows:

T

ˆY (x) =

1
k

yi,

Xxi∈Nk(x)

(2.8)

where Nk(x) is the neighborhood of x deﬁned by the k closest points xi in
the training sample. Closeness implies a metric, which for the moment we
assume is Euclidean distance. So, in words, we ﬁnd the k observations with
xi closest to x in input space, and average their responses.

In Figure 2.2 we use the same training data as in Figure 2.1, and use
15-nearest-neighbor averaging of the binary coded response as the method
of ﬁtting. Thus ˆY is the proportion of ORANGE’s in the neighborhood, and
so assigning class ORANGE to ˆG if ˆY > 0.5 amounts to a majority vote in
the neighborhood. The colored regions indicate all those points in input
space classiﬁed as BLUE or ORANGE by such a rule, in this case found by
evaluating the procedure on a ﬁne grid in input space. We see that the
decision boundaries that separate the BLUE from the ORANGE regions are far
more irregular, and respond to local clusters where one class dominates.

Figure 2.3 shows the results for 1-nearest-neighbor classiﬁcation: ˆY is
assigned the value yℓ of the closest point xℓ to x in the training data. In
this case the regions of classiﬁcation can be computed relatively easily, and
correspond to a Voronoi tessellation of the training data. Each point xi
has an associated tile bounding the region for which it is the closest input
point. For all points x in the tile, ˆG(x) = gi. The decision boundary is even
more irregular than before.

The method of k-nearest-neighbor averaging is deﬁned in exactly the
same way for regression of a quantitative output Y , although k = 1 would
be an unlikely choice.

2.3 Least Squares and Nearest Neighbors

15

15-Nearest Neighbor Classifier

o

o

o

o

o

o

o

o

o

o

o
o

o
o

o
o
o

o
o
o
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
.
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
oo
o
o
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
. . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . .
. . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

o
o
o
o
o

o
o
o
o

o
o
oo

o
o

o
o
o

o
o

o
o

... .. .. .. .. . .

o
o

o

o

o

o

o

o

.
.

o

FIGURE 2.2. The same classiﬁcation example in two dimensions as in Fig-
ure 2.1. The classes are coded as a binary variable (BLUE = 0, ORANGE = 1) and
then ﬁt by 15-nearest-neighbor averaging as in (2.8). The predicted class is hence
chosen by majority vote amongst the 15-nearest neighbors.

In Figure 2.2 we see that far fewer training observations are misclassiﬁed
than in Figure 2.1. This should not give us too much comfort, though, since
in Figure 2.3 none of the training data are misclassiﬁed. A little thought
suggests that for k-nearest-neighbor ﬁts, the error on the training data
should be approximately an increasing function of k, and will always be 0
for k = 1. An independent test set would give us a more satisfactory means
for comparing the diﬀerent methods.

It appears that k-nearest-neighbor ﬁts have a single parameter, the num-
ber of neighbors k, compared to the p parameters in least-squares ﬁts. Al-
though this is the case, we will see that the eﬀective number of parameters
of k-nearest neighbors is N/k and is generally bigger than p, and decreases
with increasing k. To get an idea of why, note that if the neighborhoods
were nonoverlapping, there would be N/k neighborhoods and we would ﬁt
one parameter (a mean) in each neighborhood.

It is also clear that we cannot use sum-of-squared errors on the training
set as a criterion for picking k, since we would always pick k = 1! It would
seem that k-nearest-neighbor methods would be more appropriate for the
mixture Scenario 2 described above, while for Gaussian data the decision
boundaries of k-nearest neighbors would be unnecessarily noisy.

16

2. Overview of Supervised Learning

1−Nearest Neighbor Classifier

o

o
o

o

o

o
o
o
o

o

o

o

o
o

o
o

o

o

o

o

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o

o
o

o
o

o
o
o
o
o
o
o
o

o

o

o

o

o

o
o
o
o
o
o
o
o
o
o

o

o
o
o
o
o

o

o
o

o
o

o

o

o
o
oo

o

o

o
o

o
o
o

o
o
o
o

o

FIGURE 2.3. The same classiﬁcation example in two dimensions as in Fig-
ure 2.1. The classes are coded as a binary variable (BLUE = 0, ORANGE = 1), and
then predicted by 1-nearest-neighbor classiﬁcation.

2.3.3 From Least Squares to Nearest Neighbors

The linear decision boundary from least squares is very smooth, and ap-
parently stable to ﬁt. It does appear to rely heavily on the assumption
that a linear decision boundary is appropriate. In language we will develop
shortly, it has low variance and potentially high bias.

On the other hand, the k-nearest-neighbor procedures do not appear to
rely on any stringent assumptions about the underlying data, and can adapt
to any situation. However, any particular subregion of the decision bound-
ary depends on a handful of input points and their particular positions,
and is thus wiggly and unstable—high variance and low bias.

Each method has its own situations for which it works best; in particular
linear regression is more appropriate for Scenario 1 above, while nearest
neighbors are more suitable for Scenario 2. The time has come to expose
the oracle! The data in fact were simulated from a model somewhere be-
tween the two, but closer to Scenario 2. First we generated 10 means mk
from a bivariate Gaussian distribution N ((1, 0)T , I) and labeled this class
BLUE. Similarly, 10 more were drawn from N ((0, 1)T , I) and labeled class
ORANGE. Then for each class we generated 100 observations as follows: for
each observation, we picked an mk at random with probability 1/10, and

2.3 Least Squares and Nearest Neighbors

17

k −  Number of Nearest Neighbors

151 101  69

 45  31  21

 11

  7   5

  3

  1

r
o
r
r

E

t
s
e
T

0
3

.

0

5
2
0

.

0
2
0

.

5
1
0

.

0
1
.
0

Linear

Train
Test
Bayes

  2

  3

  5

  8

 12

 18

 29

 67

200

Degrees of Freedom − N/k

FIGURE 2.4. Misclassiﬁcation curves for the simulation example used in Fig-
ures 2.1, 2.2 and 2.3. A single training sample of size 200 was used, and a test
sample of size 10, 000. The orange curves are test and the blue are training er-
ror for k-nearest-neighbor classiﬁcation. The results for linear regression are the
bigger orange and blue squares at three degrees of freedom. The purple line is the
optimal Bayes error rate.

then generated a N (mk, I/5), thus leading to a mixture of Gaussian clus-
ters for each class. Figure 2.4 shows the results of classifying 10,000 new
observations generated from the model. We compare the results for least
squares and those for k-nearest neighbors for a range of values of k.

A large subset of the most popular techniques in use today are variants of
these two simple procedures. In fact 1-nearest-neighbor, the simplest of all,
captures a large percentage of the market for low-dimensional problems.
The following list describes some ways in which these simple procedures
have been enhanced:

•

Kernel methods use weights that decrease smoothly to zero with dis-
tance from the target point, rather than the eﬀective 0/1 weights used
by k-nearest neighbors.

•

In high-dimensional spaces the distance kernels are modiﬁed to em-
phasize some variable more than others.

 
18

2. Overview of Supervised Learning

•

•

•

Local regression ﬁts linear models by locally weighted least squares,
rather than ﬁtting constants locally.

Linear models ﬁt to a basis expansion of the original inputs allow
arbitrarily complex models.

Projection pursuit and neural network models consist of sums of non-
linearly transformed linear models.

2.4 Statistical Decision Theory

In this section we develop a small amount of theory that provides a frame-
work for developing models such as those discussed informally so far. We
ﬁrst consider the case of a quantitative output, and place ourselves in the
IRp denote a
world of random variables and probability spaces. Let X
∈
real valued random input vector, and Y
IR a real valued random out-
put variable, with joint distribution Pr(X, Y ). We seek a function f (X)
for predicting Y given values of the input X. This theory requires a loss
function L(Y, f (X)) for penalizing errors in prediction, and by far the most
f (X))2.
common and convenient is squared error loss: L(Y, f (X)) = (Y
This leads us to a criterion for choosing f ,

−

∈

EPE(f ) = E(Y

=

[y

Z

f (X))2

f (x)]2 Pr(dx, dy),

−

−

(2.9)

(2.10)

the expected (squared) prediction error . By conditioning1 on X, we can
write EPE as

EPE(f ) = EX EY |X

[Y

f (X)]2

X

|

−

and we see that it suﬃces to minimize EPE pointwise:
(cid:1)

(cid:0)

The solution is

f (x) = argmincEY |X

[Y

c]2

|

−

X = x

.

(cid:0)

(cid:1)

f (x) = E(Y

X = x),

|

(2.11)

(2.12)

(2.13)

the conditional expectation, also known as the regression function. Thus
the best prediction of Y at any point X = x is the conditional mean, when
best is measured by average squared error.

The nearest-neighbor methods attempt to directly implement this recipe
using the training data. At each point x, we might ask for the average of all

1Conditioning here amounts to factoring the joint density Pr(X, Y ) = Pr(Y |X)Pr(X)
where Pr(Y |X) = Pr(Y, X)/Pr(X), and splitting up the bivariate integral accordingly.

2.4 Statistical Decision Theory

19

those yis with input xi = x. Since there is typically at most one observation
at any point x, we settle for

ˆf (x) = Ave(yi|

xi ∈

Nk(x)),

(2.14)

where “Ave” denotes average, and Nk(x) is the neighborhood containing
the k points in

closest to x. Two approximations are happening here:

T

•

•

expectation is approximated by averaging over sample data;

conditioning at a point is relaxed to conditioning on some region
“close” to the target point.

|

→

E(Y

→ ∞

such that k/N

For large training sample size N , the points in the neighborhood are likely
to be close to x, and as k gets large the average will get more stable.
In fact, under mild regularity conditions on the joint probability distri-
bution Pr(X, Y ), one can show that as N, k
0,
ˆf (x)
X = x). In light of this, why look further, since it seems
we have a universal approximator? We often do not have very large sam-
ples. If the linear or some more structured model is appropriate, then we
can usually get a more stable estimate than k-nearest neighbors, although
such knowledge has to be learned from the data as well. There are other
problems though, sometimes disastrous. In Section 2.5 we see that as the
dimension p gets large, so does the metric size of the k-nearest neighbor-
hood. So settling for nearest neighborhood as a surrogate for conditioning
will fail us miserably. The convergence above still holds, but the rate of
convergence decreases as the dimension increases.

→

How does linear regression ﬁt into this framework? The simplest explana-
tion is that one assumes that the regression function f (x) is approximately
linear in its arguments:

f (x)

xT β.

(2.15)

≈
This is a model-based approach—we specify a model for the regression func-
tion. Plugging this linear model for f (x) into EPE (2.9) and diﬀerentiating
we can solve for β theoretically:

β = [E(XX T )]−1E(XY ).

(2.16)

Note we have not conditioned on X; rather we have used our knowledge
of the functional relationship to pool over values of X. The least squares
solution (2.6) amounts to replacing the expectation in (2.16) by averages
over the training data.

So both k-nearest neighbors and least squares end up approximating
conditional expectations by averages. But they diﬀer dramatically in terms
of model assumptions:

•

Least squares assumes f (x) is well approximated by a globally linear
function.

20

2. Overview of Supervised Learning

•

k-nearest neighbors assumes f (x) is well approximated by a locally
constant function.

Although the latter seems more palatable, we have already seen that we
may pay a price for this ﬂexibility.

Many of the more modern techniques described in this book are model
based, although far more ﬂexible than the rigid linear model. For example,
additive models assume that

p

f (X) =

fj(Xj).

(2.17)

j=1
X
This retains the additivity of the linear model, but each coordinate function
fj is arbitrary. It turns out that the optimal estimate for the additive model
uses techniques such as k-nearest neighbors to approximate univariate con-
ditional expectations simultaneously for each of the coordinate functions.
Thus the problems of estimating a conditional expectation in high dimen-
sions are swept away in this case by imposing some (often unrealistic) model
assumptions, in this case additivity.

Are we happy with the criterion (2.11)? What happens if we replace the
? The solution in this case is the
f (X)

Y

L2 loss function with the L1: E
conditional median,

|

−

|

ˆf (x) = median(Y

X = x),

|

(2.18)

which is a diﬀerent measure of location, and its estimates are more robust
than those for the conditional mean. L1 criteria have discontinuities in
their derivatives, which have hindered their widespread use. Other more
resistant loss functions will be mentioned in later chapters, but squared
error is analytically convenient and the most popular.

What do we do when the output is a categorical variable G? The same
paradigm works here, except we need a diﬀerent loss function for penalizing
prediction errors. An estimate ˆG will assume values in
, the set of possible
K matrix L, where
classes. Our loss function can be represented by a K
). L will be zero on the diagonal and nonnegative elsewhere,
K = card(
where L(k, ℓ) is the price paid for classifying an observation belonging to
class
Gℓ. Most often we use the zero–one loss function, where all
misclassiﬁcations are charged a single unit. The expected prediction error
is

G
Gk as

G
×

EPE = E[L(G, ˆG(X))],

(2.19)

where again the expectation is taken with respect to the joint distribution
Pr(G, X). Again we condition, and can write EPE as

EPE = EX

K

Xk=1

L[

Gk, ˆG(X)]Pr(

Gk|

X)

(2.20)

2.4 Statistical Decision Theory

21

Bayes Optimal Classifier

o

o

o

o

o

o

o

o
o

o
o

o
o
o
o

o
o
o
o

. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
oo
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
oo
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
. . . .
. . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
. . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . .
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . .
oo
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . .
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . .
. . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
o
o
. .
. . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
. . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
.
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
... .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

o
o
o
o
o

o
o
o
o

o
o

o
o
o

o
o

o
o
o

o
o

o

o

o

o

o

FIGURE 2.5. The optimal Bayes decision boundary for the simulation example
of Figures 2.1, 2.2 and 2.3. Since the generating density is known for each class,
this boundary can be calculated exactly (Exercise 2.2).

and again it suﬃces to minimize EPE pointwise:

ˆG(x) = argming∈G

K

Xk=1

L(

Gk, g)Pr(

Gk|

X = x).

(2.21)

With the 0–1 loss function this simpliﬁes to

ˆG(x) = argming∈G[1

Pr(g

|

−

X = x)]

(2.22)

or simply

ˆG(x) =

Gk if Pr(

Gk|

X = x) = max
g∈G

Pr(g

|

X = x).

(2.23)

This reasonable solution is known as the Bayes classiﬁer, and says that
we classify to the most probable class, using the conditional (discrete) dis-
tribution Pr(G
X). Figure 2.5 shows the Bayes-optimal decision boundary
|
for our simulation example. The error rate of the Bayes classiﬁer is called
the Bayes rate.

22

2. Overview of Supervised Learning

Again we see that the k-nearest neighbor classiﬁer directly approximates
this solution—a majority vote in a nearest neighborhood amounts to ex-
actly this, except that conditional probability at a point is relaxed to con-
ditional probability within a neighborhood of a point, and probabilities are
estimated by training-sample proportions.

|

X) if

G1|
X) = Pr(G =

Suppose for a two-class problem we had taken the dummy-variable ap-
proach and coded G via a binary Y , followed by squared error loss estima-
tion. Then ˆf (X) = E(Y
G1 corresponded to Y = 1.
X) = Pr(G =
X). This shows
Likewise for a K-class problem, E(Yk|
that our dummy-variable regression procedure, followed by classiﬁcation to
the largest ﬁtted value, is another way of representing the Bayes classiﬁer.
Although this theory is exact, in practice problems can occur, depending
on the regression model used. For example, when linear regression is used,
ˆf (X) need not be positive, and we might be suspicious about using it as
an estimate of a probability. We will discuss a variety of approaches to
modeling Pr(G
|

X) in Chapter 4.

Gk|

2.5 Local Methods in High Dimensions

We have examined two learning techniques for prediction so far: the stable
but biased linear model and the less stable but apparently less biased class
of k-nearest-neighbor estimates. It would seem that with a reasonably large
set of training data, we could always approximate the theoretically optimal
conditional expectation by k-nearest-neighbor averaging, since we should
be able to ﬁnd a fairly large neighborhood of observations close to any x
and average them. This approach and our intuition breaks down in high
dimensions, and the phenomenon is commonly referred to as the curse
of dimensionality (Bellman, 1961). There are many manifestations of this
problem, and we will examine a few here.

Consider the nearest-neighbor procedure for inputs uniformly distributed
in a p-dimensional unit hypercube, as in Figure 2.6. Suppose we send out a
hypercubical neighborhood about a target point to capture a fraction r of
the observations. Since this corresponds to a fraction r of the unit volume,
the expected edge length will be ep(r) = r1/p. In ten dimensions e10(0.01) =
0.63 and e10(0.1) = 0.80, while the entire range for each input is only 1.0.
So to capture 1% or 10% of the data to form a local average, we must cover
63% or 80% of the range of each input variable. Such neighborhoods are no
longer “local.” Reducing r dramatically does not help much either, since
the fewer observations we average, the higher is the variance of our ﬁt.

Another consequence of the sparse sampling in high dimensions is that
all sample points are close to an edge of the sample. Consider N data points
uniformly distributed in a p-dimensional unit ball centered at the origin.
Suppose we consider a nearest-neighbor estimate at the origin. The median

2.5 Local Methods in High Dimensions

23

Unit Cube

1

0

1

Neighborhood

e
c
n
a
t
s
D

i

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

p=10

p=3
p=2

p=1

0.0

0.2

0.4

0.6

Fraction of Volume

FIGURE 2.6. The curse of dimensionality is well illustrated by a subcubical
neighborhood for uniform data in a unit cube. The ﬁgure on the right shows the
side-length of the subcube needed to capture a fraction r of the volume of the data,
for diﬀerent dimensions p. In ten dimensions we need to cover 80% of the range
of each coordinate to capture 10% of the data.

distance from the origin to the closest data point is given by the expression

d(p, N ) =

1

1/N

1/p

(2.24)

1
2

−

(cid:16)

(cid:17)

(Exercise 2.3). A more complicated expression exists for the mean distance
0.52, more than
to the closest point. For N = 500, p = 10 , d(p, N )
halfway to the boundary. Hence most data points are closer to the boundary
of the sample space than to any other data point. The reason that this
presents a problem is that prediction is much more diﬃcult near the edges
of the training sample. One must extrapolate from neighboring sample
points rather than interpolate between them.

≈

Another manifestation of the curse is that the sampling density is pro-
portional to N 1/p, where p is the dimension of the input space and N is the
sample size. Thus, if N1 = 100 represents a dense sample for a single input
problem, then N10 = 10010 is the sample size required for the same sam-
pling density with 10 inputs. Thus in high dimensions all feasible training
samples sparsely populate the input space.

Let us construct another uniform example. Suppose we have 1000 train-
1, 1]p. Assume that the true

ing examples xi generated uniformly on [
relationship between X and Y is

−

Y = f (X) = e−8||X||2

,

without any measurement error. We use the 1-nearest-neighbor rule to
. We can
predict y0 at the test-point x0 = 0. Denote the training set by

T

24

2. Overview of Supervised Learning

compute the expected prediction error at x0 for our procedure, averaging
over all such samples of size 1000. Since the problem is deterministic, this
is the mean squared error (MSE) for estimating f (0):

MSE(x0) = ET [f (x0)
= ET [ˆy0 −
= VarT (ˆy0) + Bias2(ˆy0).

−
ET (ˆy0)]2 + [ET (ˆy0)

ˆy0]2

f (x0)]2

−

(2.25)

Figure 2.7 illustrates the setup. We have broken down the MSE into two
components that will become familiar as we proceed: variance and squared
bias. Such a decomposition is always possible and often useful, and is known
as the bias–variance decomposition. Unless the nearest neighbor is at 0,
ˆy0 will be smaller than f (0) in this example, and so the average estimate
will be biased downward. The variance is due to the sampling variance of
the 1-nearest neighbor. In low dimensions and with N = 1000, the nearest
neighbor is very close to 0, and so both the bias and variance are small. As
the dimension increases, the nearest neighbor tends to stray further from
the target point, and both bias and variance are incurred. By p = 10, for
more than 99% of the samples the nearest neighbor is a distance greater
than 0.5 from the origin. Thus as p increases, the estimate tends to be 0
more often than not, and hence the MSE levels oﬀ at 1.0, as does the bias,
and the variance starts dropping (an artifact of this example).

Although this is a highly contrived example, similar phenomena occur
more generally. The complexity of functions of many variables can grow
exponentially with the dimension, and if we wish to be able to estimate
such functions with the same accuracy as function in low dimensions, then
we need the size of our training set to grow exponentially as well. In this
example, the function is a complex interaction of all p variables involved.
The dependence of the bias term on distance depends on the truth, and
it need not always dominate with 1-nearest neighbor. For example, if the
function always involves only a few dimensions as in Figure 2.8, then the
variance can dominate instead.

Suppose, on the other hand, that we know that the relationship between

Y and X is linear,

Y = X T β + ε,

(2.26)

∼

N (0, σ2) and we ﬁt the model by least squares to the train-
where ε
ˆβ, which can
ing data. For an arbitrary test point x0, we have ˆy0 = xT
0
N
be written as ˆy0 = xT
i=1 ℓi(x0)εi, where ℓi(x0) is the ith element
of X(XT X)−1x0. Since under this model the least squares estimates are

0 β +

P

2.5 Local Methods in High Dimensions

25

1-NN in One Dimension

1-NN in One vs. Two Dimensions

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.

0

8
0

.

6
0

.

4

.

0

2
0

.

0
0

.

)

X

(
f

r
o
b
h
g
e
N

i

t
s
e
r
a
e
N
o

t

i

e
c
n
a
t
s
D
e
g
a
r
e
v
A

•

•

•

•

•
•
•

•

•

0
.
1

5
.
0

2
X

0
.
0

5
.
0
-

.

0
1
-

-1.0

-0.5

0.0

X

0.5

1.0

-1.0

-0.5

•

•

•

•
•
•

•

•

•

•

•

•

•

•

•

•

•

•

0.0

X1

0.5

1.0

Distance to 1-NN vs. Dimension

MSE vs. Dimension

•

•

•

•

•

•

•

•

4

6

8

10

•

•

2

e
s
M

0

.

1

8

.

0

6
0

.

4

.

0

2

.

0

0
0

.

•
•
•

MSE
Variance
Sq. Bias

•
•

•
•

•
•

•
•

•
•

•

6

•
•

•

•
•
•

•
•
•

•
•
•

2

•
•
•

4

•

•

8

•

•

10

Dimension

Dimension

−

FIGURE 2.7. A simulation example, demonstrating the curse of dimensional-
ity and its eﬀect on MSE, bias and variance. The input features are uniformly
1, 1]p for p = 1, . . . , 10 The top left panel shows the target func-
distributed in [
tion (no noise) in IR: f (X) = e−8||X||2
, and demonstrates the error that 1-nearest
neighbor makes in estimating f (0). The training point is indicated by the blue tick
mark. The top right panel illustrates why the radius of the 1-nearest neighborhood
increases with dimension p. The lower left panel shows the average radius of the
1-nearest neighborhoods. The lower-right panel shows the MSE, squared bias and
variance curves as a function of dimension p.

 
 
 
 
26

2. Overview of Supervised Learning

1-NN in One Dimension

MSE  vs. Dimension

4

3

)

X

(
f

2

1

0

•

0.0

X

0.5

1.0

-1.0

-0.5

E
S
M

5
2
.
0

0
2
.
0

5
1
.
0

0
1
.
0

5
0
.
0

0
.
0

•
•
•

MSE
Variance
Sq. Bias

•
•

•

•
•
•

4

•
•
•

•
•
•

•
•
•

2

•
•

•

•
•

•

10

•
•

•
•

•

•

8

•
•

•

6

Dimension

FIGURE 2.8. A simulation example with the same setup as in Figure 2.7. Here
2 (X1 + 1)3. The
the function is constant in all but one dimension: F (X) = 1
variance dominates.

unbiased, we ﬁnd that

ˆy0)2

EPE(x0) = Ey0|x0 ET (y0 −
= Var(y0|
= Var(y0|
= σ2 + ET xT

ET ˆy0]2 + [ET ˆy0 −

x0) + ET [ˆy0 −
x0) + VarT (ˆy0) + Bias2(ˆy0)
0 (XT X)−1x0σ2 + 02.

0 β]2
xT

(2.27)

Here we have incurred an additional variance σ2 in the prediction error,
since our target is not deterministic. There is no bias, and the variance
depends on x0. If N is large and
were selected at random, and assuming
E(X) = 0, then XT X

T
N Cov(X) and

→

Ex0EPE(x0)

Ex0xT

0 Cov(X)−1x0σ2/N + σ2

∼
= trace[Cov(X)−1Cov(x0)]σ2/N + σ2
= σ2(p/N ) + σ2.

(2.28)

Here we see that the expected EPE increases linearly as a function of p,
with slope σ2/N . If N is large and/or σ2 is small, this growth in vari-
ance is negligible (0 in the deterministic case). By imposing some heavy
restrictions on the class of models being ﬁtted, we have avoided the curse
of dimensionality. Some of the technical details in (2.27) and (2.28) are
derived in Exercise 2.5.

Figure 2.9 compares 1-nearest neighbor vs. least squares in two situa-
tions, both of which have the form Y = f (X) + ε, X uniform as before,
N (0, 1). The sample size is N = 500. For the orange curve, f (x)
and ε

∼

2.5 Local Methods in High Dimensions

27

Expected Prediction Error of 1NN vs. OLS

o

i
t

a
R
E
P
E

1

.

2

0

.

2

9
1

.

8
1

.

7

.

1

6
1

.

•

•

•

•

•

•

•
•

Linear
Cubic

•

•

•

2

•

4

•

•

6

Dimension

•

•

•

•

8

•

•

•

•

10

FIGURE 2.9. The curves show the expected prediction error (at x0 = 0) for
1-nearest neighbor relative to least squares for the model Y = f (X) + ε. For the
orange curve, f (x) = x1, while for the blue curve f (x) = 1

2 (x1 + 1)3.

is linear in the ﬁrst coordinate, for the blue curve, cubic as in Figure 2.8.
Shown is the relative EPE of 1-nearest neighbor to least squares, which
appears to start at around 2 for the linear case. Least squares is unbiased
in this case, and as discussed above the EPE is slightly above σ2 = 1.
The EPE for 1-nearest neighbor is always above 2, since the variance of
ˆf (x0) in this case is at least σ2, and the ratio increases with dimension as
the nearest neighbor strays from the target point. For the cubic case, least
squares is biased, which moderates the ratio. Clearly we could manufacture
examples where the bias of least squares would dominate the variance, and
the 1-nearest neighbor would come out the winner.

By relying on rigid assumptions, the linear model has no bias at all and
negligible variance, while the error in 1-nearest neighbor is substantially
larger. However, if the assumptions are wrong, all bets are oﬀ and the
1-nearest neighbor may dominate. We will see that there is a whole spec-
trum of models between the rigid linear models and the extremely ﬂexible
1-nearest-neighbor models, each with their own assumptions and biases,
which have been proposed speciﬁcally to avoid the exponential growth in
complexity of functions in high dimensions by drawing heavily on these
assumptions.

Before we delve more deeply, let us elaborate a bit on the concept of

statistical models and see how they ﬁt into the prediction framework.

 
28

2. Overview of Supervised Learning

2.6 Statistical Models, Supervised Learning and

Function Approximation

Our goal is to ﬁnd a useful approximation ˆf (x) to the function f (x) that
underlies the predictive relationship between the inputs and outputs. In the
theoretical setting of Section 2.4, we saw that squared error loss lead us
to the regression function f (x) = E(Y
X = x) for a quantitative response.
The class of nearest-neighbor methods can be viewed as direct estimates
of this conditional expectation, but we have seen that they can fail in at
least two ways:

|

•

•

if the dimension of the input space is high, the nearest neighbors need
not be close to the target point, and can result in large errors;

if special structure is known to exist, this can be used to reduce both
the bias and the variance of the estimates.

We anticipate using other classes of models for f (x), in many cases specif-
ically designed to overcome the dimensionality problems, and here we dis-
cuss a framework for incorporating them into the prediction problem.

2.6.1 A Statistical Model for the Joint Distribution Pr(X, Y )

Suppose in fact that our data arose from a statistical model

Y = f (X) + ε,

(2.29)

|

where the random error ε has E(ε) = 0 and is independent of X. Note that
for this model, f (x) = E(Y
X = x), and in fact the conditional distribution
Pr(Y

X) depends on X only through the conditional mean f (x).

|

The additive error model is a useful approximation to the truth. For
most systems the input–output pairs (X, Y ) will not have a deterministic
relationship Y = f (X). Generally there will be other unmeasured variables
that also contribute to Y , including measurement error. The additive model
assumes that we can capture all these departures from a deterministic re-
lationship via the error ε.

For some problems a deterministic relationship does hold. Many of the
classiﬁcation problems studied in machine learning are of this form, where
the response surface can be thought of as a colored map deﬁned in IRp.
The training data consist of colored examples from the map
, and
the goal is to be able to color any point. Here the function is deterministic,
and the randomness enters through the x location of the training points.
For the moment we will not pursue such problems, but will see that they
can be handled by techniques appropriate for the error-based models.

xi, gi}
{

The assumption in (2.29) that the errors are independent and identically
distributed is not strictly necessary, but seems to be at the back of our mind

2.6 Statistical Models, Supervised Learning and Function Approximation

29

when we average squared errors uniformly in our EPE criterion. With such
a model it becomes natural to use least squares as a data criterion for
model estimation as in (2.1). Simple modiﬁcations can be made to avoid
the independence assumption; for example, we can have Var(Y
X = x) =
σ(x), and now both the mean and variance depend on X. In general the
X) can depend on X in complicated ways,
conditional distribution Pr(Y
but the additive error model precludes these.

|

|

So far we have concentrated on the quantitative response. Additive error
models are typically not used for qualitative outputs G; in this case the tar-
X), and this is modeled
get function p(X) is the conditional density Pr(G
|
directly. For example, for two-class data, it is often reasonable to assume
that the data arise from independent binary trials, with the probability of
one particular outcome being p(X), and the other 1
p(X). Thus if Y is
the 0–1 coded version of G, then E(Y
X = x) = p(x), but the variance
depends on x as well: Var(Y

X = x) = p(x)[1

p(x)].

−

|

|

−

2.6.2 Supervised Learning

Before we launch into more statistically oriented jargon, we present the
function-ﬁtting paradigm from a machine learning point of view. Suppose
for simplicity that the errors are additive and that the model Y = f (X) + ε
is a reasonable assumption. Supervised learning attempts to learn f by
example through a teacher. One observes the system under study, both
the inputs and outputs, and assembles a training set of observations
=
(xi, yi), i = 1, . . . , N . The observed input values to the system xi are also
fed into an artiﬁcial system, known as a learning algorithm (usually a com-
puter program), which also produces outputs ˆf (xi) in response to the in-
puts. The learning algorithm has the property that it can modify its in-
ˆf (xi) between the
put/output relationship ˆf in response to diﬀerences yi −
original and generated outputs. This process is known as learning by exam-
ple. Upon completion of the learning process the hope is that the artiﬁcial
and real outputs will be close enough to be useful for all sets of inputs likely
to be encountered in practice.

T

2.6.3 Function Approximation

The learning paradigm of the previous section has been the motivation
for research into the supervised learning problem in the ﬁelds of machine
learning (with analogies to human reasoning) and neural networks (with
biological analogies to the brain). The approach taken in applied mathe-
matics and statistics has been from the perspective of function approxima-
tion and estimation. Here the data pairs
are viewed as points in a
(p + 1)-dimensional Euclidean space. The function f (x) has domain equal
to the p-dimensional input subspace, and is related to the data via a model

xi, yi}
{

30

2. Overview of Supervised Learning

such as yi = f (xi) + εi. For convenience in this chapter we will assume the
domain is IRp, a p-dimensional Euclidean space, although in general the
inputs can be of mixed type. The goal is to obtain a useful approximation
to f (x) for all x in some region of IRp, given the representations in
.
Although somewhat less glamorous than the learning paradigm, treating
supervised learning as a problem in function approximation encourages the
geometrical concepts of Euclidean spaces and mathematical concepts of
probabilistic inference to be applied to the problem. This is the approach
taken in this book.

T

Many of the approximations we will encounter have associated a set of
parameters θ that can be modiﬁed to suit the data at hand. For example,
the linear model f (x) = xT β has θ = β. Another class of useful approxi-
mators can be expressed as linear basis expansions

K

fθ(x) =

hk(x)θk,

(2.30)

Xk=1
where the hk are a suitable set of functions or transformations of the input
vector x. Traditional examples are polynomial and trigonometric expan-
sions, where for example hk might be x2
2, cos(x1) and so on. We
also encounter nonlinear expansions, such as the sigmoid transformation
common to neural network models,

1, x1x2

hk(x) =

1
1 + exp(

−

.

xT βk)

(2.31)

We can use least squares to estimate the parameters θ in fθ as we did

for the linear model, by minimizing the residual sum-of-squares

RSS(θ) =

N

i=1
X

fθ(xi))2

(yi −

(2.32)

as a function of θ. This seems a reasonable criterion for an additive error
model. In terms of function approximation, we imagine our parameterized
function as a surface in p + 1 space, and what we observe are noisy re-
alizations from it. This is easy to visualize when p = 2 and the vertical
coordinate is the output y, as in Figure 2.10. The noise is in the output
coordinate, so we ﬁnd the set of parameters such that the ﬁtted surface
gets as close to the observed points as possible, where close is measured by
the sum of squared vertical errors in RSS(θ).

For the linear model we get a simple closed form solution to the mini-
mization problem. This is also true for the basis function methods, if the
basis functions themselves do not have any hidden parameters. Otherwise
the solution requires either iterative methods or numerical optimization.

While least squares is generally very convenient, it is not the only crite-
rion used and in some cases would not make much sense. A more general

2.6 Statistical Models, Supervised Learning and Function Approximation

31

•
•

•
•
•
•
•

•
•
•
•
•
•
•

•
•
•

•
•

•
•

•

•
•
•

•
•
•

•
•
•
•
•
••
•
•
•
•
•
•

•
•
•

•

•

•
••
•
•
•

•

•• •
•
•
•
•
•

•
•
•
•

•

•
•

•

•

•
•

•
•

FIGURE 2.10. Least squares ﬁtting of a function of two inputs. The parameters
of fθ(x) are chosen so as to minimize the sum-of-squared vertical errors.

principle for estimation is maximum likelihood estimation. Suppose we have
a random sample yi, i = 1, . . . , N from a density Prθ(y) indexed by some
parameters θ. The log-probability of the observed sample is

N

L(θ) =

log Prθ(yi).

i=1
X

(2.33)

The principle of maximum likelihood assumes that the most reasonable
values for θ are those for which the probability of the observed sample is
largest. Least squares for the additive error model Y = fθ(X) + ε, with
N (0, σ2), is equivalent to maximum likelihood using the conditional
ε
likelihood

∼

Pr(Y

|

X, θ) = N (fθ(X), σ2).

(2.34)

So although the additional assumption of normality seems more restrictive,
the results are the same. The log-likelihood of the data is

L(θ) =

N
2

−

log(2π)

N log σ

−

1
2σ2

−

N

i=1
X

fθ(xi))2,

(yi −

(2.35)

and the only term involving θ is the last, which is RSS(θ) up to a scalar
negative multiplier.

A more interesting example is the multinomial likelihood for the regres-
sion function Pr(G
X) for a qualitative output G. Suppose we have a model
|
X = x) = pk,θ(x), k = 1, . . . , K for the conditional probabil-
Pr(G =
Gk|
ity of each class given X, indexed by the parameter vector θ. Then the

32

2. Overview of Supervised Learning

log-likelihood (also referred to as the cross-entropy) is

N

L(θ) =

log pgi,θ(xi),

(2.36)

i=1
X

and when maximized it delivers values of θ that best conform with the data
in this likelihood sense.

2.7 Structured Regression Models

We have seen that although nearest-neighbor and other local methods focus
directly on estimating the function at a point, they face problems in high
dimensions. They may also be inappropriate even in low dimensions in
cases where more structured approaches can make more eﬃcient use of the
data. This section introduces classes of such structured approaches. Before
we proceed, though, we discuss further the need for such classes.

2.7.1 Diﬃculty of the Problem

Consider the RSS criterion for an arbitrary function f ,

RSS(f ) =

N

i=1
X

f (xi))2.

(yi −

(2.37)

Minimizing (2.37) leads to inﬁnitely many solutions: any function ˆf passing
through the training points (xi, yi) is a solution. Any particular solution
chosen might be a poor predictor at test points diﬀerent from the training
points. If there are multiple observation pairs xi, yiℓ, ℓ = 1, . . . , Ni at each
value of xi, the risk is limited. In this case, the solutions pass through
the average values of the yiℓ at each xi; see Exercise 2.6. The situation is
similar to the one we have already visited in Section 2.4; indeed, (2.37) is
the ﬁnite sample version of (2.11) on page 18. If the sample size N were
suﬃciently large such that repeats were guaranteed and densely arranged,
it would seem that these solutions might all tend to the limiting conditional
expectation.

In order to obtain useful results for ﬁnite N , we must restrict the eligible
solutions to (2.37) to a smaller set of functions. How to decide on the
nature of the restrictions is based on considerations outside of the data.
These restrictions are sometimes encoded via the parametric representation
of fθ, or may be built into the learning method itself, either implicitly or
explicitly. These restricted classes of solutions are the major topic of this
book. One thing should be clear, though. Any restrictions imposed on f
that lead to a unique solution to (2.37) do not really remove the ambiguity

2.8 Classes of Restricted Estimators

33

caused by the multiplicity of solutions. There are inﬁnitely many possible
restrictions, each leading to a unique solution, so the ambiguity has simply
been transferred to the choice of constraint.

In general the constraints imposed by most learning methods can be
described as complexity restrictions of one kind or another. This usually
means some kind of regular behavior in small neighborhoods of the input
space. That is, for all input points x suﬃciently close to each other in
some metric, ˆf exhibits some special structure such as nearly constant,
linear or low-order polynomial behavior. The estimator is then obtained by
averaging or polynomial ﬁtting in that neighborhood.

The strength of the constraint is dictated by the neighborhood size. The
larger the size of the neighborhood, the stronger the constraint, and the
more sensitive the solution is to the particular choice of constraint. For
example, local constant ﬁts in inﬁnitesimally small neighborhoods is no
constraint at all; local linear ﬁts in very large neighborhoods is almost a
globally linear model, and is very restrictive.

The nature of the constraint depends on the metric used. Some methods,
such as kernel and local regression and tree-based methods, directly specify
the metric and size of the neighborhood. The nearest-neighbor methods
discussed so far are based on the assumption that locally the function is
constant; close to a target input x0, the function does not change much, and
so close outputs can be averaged to produce ˆf (x0). Other methods such
as splines, neural networks and basis-function methods implicitly deﬁne
neighborhoods of local behavior. In Section 5.4.1 we discuss the concept
of an equivalent kernel (see Figure 5.8 on page 157), which describes this
local dependence for any method linear in the outputs. These equivalent
kernels in many cases look just like the explicitly deﬁned weighting kernels
discussed above—peaked at the target point and falling away smoothly
away from it.

One fact should be clear by now. Any method that attempts to pro-
duce locally varying functions in small isotropic neighborhoods will run
into problems in high dimensions—again the curse of dimensionality. And
conversely, all methods that overcome the dimensionality problems have an
associated—and often implicit or adaptive—metric for measuring neighbor-
hoods, which basically does not allow the neighborhood to be simultane-
ously small in all directions.

2.8 Classes of Restricted Estimators

The variety of nonparametric regression techniques or learning methods fall
into a number of diﬀerent classes depending on the nature of the restrictions
imposed. These classes are not distinct, and indeed some methods fall in
several classes. Here we give a brief summary, since detailed descriptions

34

2. Overview of Supervised Learning

are given in later chapters. Each of the classes has associated with it one
or more parameters, sometimes appropriately called smoothing parameters,
that control the eﬀective size of the local neighborhood. Here we describe
three broad classes.

2.8.1 Roughness Penalty and Bayesian Methods

Here the class of functions is controlled by explicitly penalizing RSS(f )
with a roughness penalty

PRSS(f ; λ) = RSS(f ) + λJ(f ).

(2.38)

The user-selected functional J(f ) will be large for functions f that vary too
rapidly over small regions of input space. For example, the popular cubic
smoothing spline for one-dimensional inputs is the solution to the penalized
least-squares criterion

PRSS(f ; λ) =

N

i=1
X

(yi −

f (xi))2 + λ

[f ′′(x)]2dx.

(2.39)

Z

The roughness penalty here controls large values of the second derivative
0. For λ = 0 no penalty
of f , and the amount of penalty is dictated by λ
only
is imposed, and any interpolating function will do, while for λ =
functions linear in x are permitted.

∞

≥

Penalty functionals J can be constructed for functions in any dimension,
and special versions can be created to impose special structure. For ex-
p
ample, additive penalties J(f ) =
j=1 J(fj) are used in conjunction with
p
j=1 fj(Xj) to create additive models with
additive functions f (X) =
smooth coordinate functions. Similarly, projection pursuit regression mod-
P
M
m=1 gm(αT
els have f (X) =
mX) for adaptively chosen directions αm, and
the functions gm can each have an associated roughness penalty.

P

Penalty function, or regularization methods, express our prior belief that
the type of functions we seek exhibit a certain type of smooth behavior, and
indeed can usually be cast in a Bayesian framework. The penalty J corre-
sponds to a log-prior, and PRSS(f ; λ) the log-posterior distribution, and
minimizing PRSS(f ; λ) amounts to ﬁnding the posterior mode. We discuss
roughness-penalty approaches in Chapter 5 and the Bayesian paradigm in
Chapter 8.

P

2.8.2 Kernel Methods and Local Regression

These methods can be thought of as explicitly providing estimates of the re-
gression function or conditional expectation by specifying the nature of the
local neighborhood, and of the class of regular functions ﬁtted locally. The
local neighborhood is speciﬁed by a kernel function Kλ(x0, x) which assigns

2.8 Classes of Restricted Estimators

35

weights to points x in a region around x0 (see Figure 6.1 on page 192). For
example, the Gaussian kernel has a weight function based on the Gaussian
density function

Kλ(x0, x) =

1
λ

exp

−

(cid:20)

x

||

2

x0||
−
2λ

(cid:21)

(2.40)

and assigns weights to points that die exponentially with their squared
Euclidean distance from x0. The parameter λ corresponds to the variance
of the Gaussian density, and controls the width of the neighborhood. The
simplest form of kernel estimate is the Nadaraya–Watson weighted average

ˆf (x0) =

N
i=1 Kλ(x0, xi)yi
N
i=1 Kλ(x0, xi)

.

P

(2.41)

In general we can deﬁne a local regression estimate of f (x0) as fˆθ(x0),
where ˆθ minimizes

P

RSS(fθ, x0) =

N

i=1
X

Kλ(x0, xi)(yi −

fθ(xi))2,

(2.42)

and fθ is some parameterized function, such as a low-order polynomial.
Some examples are:

fθ(x) = θ0, the constant function; this results in the Nadaraya–
Watson estimate in (2.41) above.

fθ(x) = θ0 + θ1x gives the popular local linear regression model.

•

•

Nearest-neighbor methods can be thought of as kernel methods having a
more data-dependent metric. Indeed, the metric for k-nearest neighbors is

Kk(x, x0) = I(

x

x0|| ≤ ||

x(k) −

x0||

),

−
where x(k) is the training observation ranked kth in distance from x0, and
I(S) is the indicator of the set S.

||

These methods of course need to be modiﬁed in high dimensions, to avoid
the curse of dimensionality. Various adaptations are discussed in Chapter 6.

2.8.3 Basis Functions and Dictionary Methods

This class of methods includes the familiar linear and polynomial expan-
sions, but more importantly a wide variety of more ﬂexible models. The
model for f is a linear expansion of basis functions

M

fθ(x) =

θmhm(x),

m=1
X

(2.43)

36

2. Overview of Supervised Learning

where each of the hm is a function of the input x, and the term linear here
refers to the action of the parameters θ. This class covers a wide variety of
methods. In some cases the sequence of basis functions is prescribed, such
as a basis for polynomials in x of total degree M .

−

−

For one-dimensional x, polynomial splines of degree K can be represented
by an appropriate sequence of M spline basis functions, determined in turn
by M
K knots. These produce functions that are piecewise polynomials
of degree K between the knots, and joined up with continuity of degree
K
1 at the knots. As an example consider linear splines, or piecewise
linear functions. One intuitively satisfying basis consists of the functions
b1(x) = 1, b2(x) = x, and bm+2(x) = (x
2,
where tm is the mth knot, and z+ denotes positive part. Tensor products
of spline bases can be used for inputs with dimensions larger than one
(see Section 5.2, and the CART and MARS models in Chapter 9.) The
parameter θ can be the total degree of the polynomial or the number of
knots in the case of splines.

tm)+, m = 1, . . . , M

−

−

Radial basis functions are symmetric p-dimensional kernels located at

particular centroids,

M

fθ(x) =

Kλm (µm, x)θm;

(2.44)

m=1
X
for example, the Gaussian kernel Kλ(µ, x) = e−||x−µ||2/2λ is popular.

Radial basis functions have centroids µm and scales λm that have to
be determined. The spline basis functions have knots. In general we would
like the data to dictate them as well. Including these as parameters changes
the regression problem from a straightforward linear problem to a combi-
natorially hard nonlinear problem. In practice, shortcuts such as greedy
algorithms or two stage processes are used. Section 6.7 describes some such
approaches.

A single-layer feed-forward neural network model with linear output
weights can be thought of as an adaptive basis function method. The model
has the form

fθ(x) =

M

m=1
X

βmσ(αT

mx + bm),

(2.45)

where σ(x) = 1/(1 + e−x) is known as the activation function. Here, as
in the projection pursuit model, the directions αm and the bias terms bm
have to be determined, and their estimation is the meat of the computation.
Details are give in Chapter 11.

These adaptively chosen basis function methods are also known as dictio-
nary methods, where one has available a possibly inﬁnite set or dictionary
of candidate basis functions from which to choose, and models are built

D
up by employing some kind of search mechanism.

2.9 Model Selection and the Bias–Variance Tradeoﬀ

37

2.9 Model Selection and the Bias–Variance

Tradeoﬀ

All the models described above and many others discussed in later chapters
have a smoothing or complexity parameter that has to be determined:

the multiplier of the penalty term;

the width of the kernel;

or the number of basis functions.

•

•

•

In the case of the smoothing spline, the parameter λ indexes models ranging
from a straight line ﬁt to the interpolating model. Similarly a local degree-
m polynomial model ranges between a degree-m global polynomial when
the window size is inﬁnitely large, to an interpolating ﬁt when the window
size shrinks to zero. This means that we cannot use residual sum-of-squares
on the training data to determine these parameters as well, since we would
always pick those that gave interpolating ﬁts and hence zero residuals. Such
a model is unlikely to predict future data well at all.

The k-nearest-neighbor regression ﬁt ˆfk(x0) usefully illustrates the com-
peting forces that aﬀect the predictive ability of such approximations. Sup-
pose the data arise from a model Y = f (X) + ε, with E(ε) = 0 and
Var(ε) = σ2. For simplicity here we assume that the values of xi in the
sample are ﬁxed in advance (nonrandom). The expected prediction error
at x0, also known as test or generalization error, can be decomposed:

EPEk(x0) = E[(Y

ˆfk(x0))2

X = x0]

−

|
= σ2 + [Bias2( ˆfk(x0)) + VarT ( ˆfk(x0))]
σ2
k

= σ2 +

f (x(ℓ))

1
k

+

−

k

2

.

f (x0)
h

Xℓ=1

i

(2.46)

(2.47)

The subscripts in parentheses (ℓ) indicate the sequence of nearest neighbors
to x0.

There are three terms in this expression. The ﬁrst term σ2 is the ir-
reducible error—the variance of the new test target—and is beyond our
control, even if we know the true f (x0).

The second and third terms are under our control, and make up the
mean squared error of ˆfk(x0) in estimating f (x0), which is broken down
into a bias component and a variance component. The bias term is the
squared diﬀerence between the true mean f (x0) and the expected value of
the estimate—[ET ( ˆfk(x0))
f (x0)]2—where the expectation averages the
randomness in the training data. This term will most likely increase with
k, if the true function is reasonably smooth. For small k the few closest
neighbors will have values f (x(ℓ)) close to f (x0), so their average should

−

38

2. Overview of Supervised Learning

High Bias
Low Variance

Low Bias
High Variance

r
o
r
r
E
n
o
i
t
c
i
d
e
r
P

Test Sample

Training Sample

Low

High

Model Complexity

FIGURE 2.11. Test and training error as a function of model complexity.

be close to f (x0). As k grows, the neighbors are further away, and then
anything can happen.

The variance term is simply the variance of an average here, and de-
creases as the inverse of k. So as k varies, there is a bias–variance tradeoﬀ.
More generally, as the model complexity of our procedure is increased, the
variance tends to increase and the squared bias tends to decrease. The op-
posite behavior occurs as the model complexity is decreased. For k-nearest
neighbors, the model complexity is controlled by k.

Typically we would like to choose our model complexity to trade bias
oﬀ with variance in such a way as to minimize the test error. An obvious
estimate of test error is the training error 1
ˆyi)2. Unfortunately
N
training error is not a good estimate of test error, as it does not properly
account for model complexity.

i(yi −

P

Figure 2.11 shows the typical behavior of the test and training error, as
model complexity is varied. The training error tends to decrease whenever
we increase the model complexity, that is, whenever we ﬁt the data harder.
However with too much ﬁtting, the model adapts itself too closely to the
training data, and will not generalize well (i.e., have large test error). In
that case the predictions ˆf (x0) will have large variance, as reﬂected in the
last term of expression (2.46). In contrast, if the model is not complex
enough, it will underﬁt and may have large bias, again resulting in poor
generalization. In Chapter 7 we discuss methods for estimating the test
error of a prediction method, and hence estimating the optimal amount of
model complexity for a given prediction method and training set.

Exercises

39

Bibliographic Notes

Some good general books on the learning problem are Duda et al. (2000),
Bishop (1995),(Bishop, 2006), Ripley (1996), Cherkassky and Mulier (2007)
and Vapnik (1996). Parts of this chapter are based on Friedman (1994b).

Exercises

Ex. 2.1 Suppose each of K-classes has an associated target tk, which is a
vector of all zeros, except a one in the kth position. Show that classifying to
tk −
the largest element of ˆy amounts to choosing the closest target, mink ||
ˆy
||

, if the elements of ˆy sum to one.

Ex. 2.2 Show how to compute the Bayes decision boundary for the simula-
tion example in Figure 2.5.

Ex. 2.3 Derive equation (2.24).

Ex. 2.4 The edge eﬀect problem discussed on page 23 is not peculiar to
uniform sampling from bounded domains. Consider inputs drawn from a
N (0, Ip). The squared distance
spherical multinormal distribution X
from any sample point to the origin has a χ2
p distribution with mean p.
Consider a prediction point x0 drawn from this distribution, and let a =
be an associated unit vector. Let zi = aT xi be the projection of
x0/
each of the training points on this direction.

x0||

∼

||

Show that the zi are distributed N (0, 1) with expected squared distance
from the origin 1, while the target point has expected squared distance p
from the origin.

Hence for p = 10, a randomly drawn test point is about 3.1 standard
deviations from the origin, while all the training points are on average
one standard deviation along direction a. So most prediction points see
themselves as lying on the edge of the training set.

Ex. 2.5

(a) Derive equation (2.27). The last line makes use of (3.8) through a

conditioning argument.

(b) Derive equation (2.28), making use of the cyclic property of the trace
operator [trace(AB) = trace(BA)], and its linearity (which allows us
to interchange the order of trace and expectation).

Ex. 2.6 Consider a regression problem with inputs xi and outputs yi, and a
parameterized model fθ(x) to be ﬁt by least squares. Show that if there are
observations with tied or identical values of x, then the ﬁt can be obtained
from a reduced weighted least squares problem.

40

2. Overview of Supervised Learning

Ex. 2.7 Suppose we have a sample of N pairs xi, yi drawn i.i.d. from the
distribution characterized as follows:

h(x), the design density

xi ∼
yi = f (xi) + εi, f is the regression function
(0, σ2) (mean zero, variance σ2)
εi ∼

We construct an estimator for f linear in the yi,

ˆf (x0) =

N

i=1
X

ℓi(x0;

)yi,

X

where the weights ℓi(x0;
entire training sequence of xi, denoted here by

) do not depend on the yi, but do depend on the
.

X

X

(a) Show that linear regression and k-nearest-neighbor regression are mem-
bers of this class of estimators. Describe explicitly the weights ℓi(x0;
)
in each of these cases.

X

(b) Decompose the conditional mean-squared error

EY|X (f (x0)

ˆf (x0))2

−

into a conditional squared bias and a conditional variance component.
represents the entire training sequence of yi.
Like

,

X

Y

(c) Decompose the (unconditional) mean-squared error

EY,X (f (x0)

ˆf (x0))2

−

into a squared bias and a variance component.

(d) Establish a relationship between the squared biases and variances in

the above two cases.

Ex. 2.8 Compare the classiﬁcation performance of linear regression and k–
nearest neighbor classiﬁcation on the zipcode data. In particular, consider
only the 2’s and 3’s, and k = 1, 3, 5, 7 and 15. Show both the training and
test error for each choice. The zipcode data are available from the book
website www-stat.stanford.edu/ElemStatLearn.

Ex. 2.9 Consider a linear regression model with p parameters, ﬁt by least
squares to a set of training data (x1, y1), . . . , (xN , yN ) drawn at random
from a population. Let ˆβ be the least squares estimate. Suppose we have
some test data (˜x1, ˜y1), . . . , (˜xM , ˜yM ) drawn at random from the same pop-
ulation as the training data. If Rtr(β) = 1
βT xi)2 and Rte(β) =
N
1
βT ˜xi)2, prove that
M

1 (yi −

M

N

1 (˜yi −

P

E[Rtr( ˆβ)]

≤

P
E[Rte( ˆβ)],

where the expectations are over all that is random in each expression. [This
exercise was brought to our attention by Ryan Tibshirani, from a homework
assignment given by Andrew Ng.]

Exercises

41

42

2. Overview of Supervised Learning

3
Linear Methods for Regression

This is page 43
Printer: Opaque this

3.1

Introduction

|

X) is
A linear regression model assumes that the regression function E(Y
linear in the inputs X1, . . . , Xp. Linear models were largely developed in
the precomputer age of statistics, but even in today’s computer era there
are still good reasons to study and use them. They are simple and often
provide an adequate and interpretable description of how the inputs aﬀect
the output. For prediction purposes they can sometimes outperform fancier
nonlinear models, especially in situations with small numbers of training
cases, low signal-to-noise ratio or sparse data. Finally, linear methods can be
applied to transformations of the inputs and this considerably expands their
scope. These generalizations are sometimes called basis-function methods,
and are discussed in Chapter 5.

In this chapter we describe linear methods for regression, while in the
next chapter we discuss linear methods for classiﬁcation. On some topics we
go into considerable detail, as it is our ﬁrm belief that an understanding
of linear methods is essential for understanding nonlinear ones. In fact,
many nonlinear techniques are direct generalizations of the linear methods
discussed here.

44

3. Linear Methods for Regression

3.2 Linear Regression Models and Least Squares

As introduced in Chapter 2, we have an input vector X T = (X1, X2, . . . , Xp),
and want to predict a real-valued output Y . The linear regression model
has the form

p

f (X) = β0 +

Xjβj.

(3.1)

j=1
X

The linear model either assumes that the regression function E(Y
X) is
linear, or that the linear model is a reasonable approximation. Here the
βj’s are unknown parameters or coeﬃcients, and the variables Xj can come
from diﬀerent sources:

|

•

•

•

•

quantitative inputs;

transformations of quantitative inputs, such as log, square-root or
square;

basis expansions, such as X2 = X 2
representation;

1 , X3 = X 3

1 , leading to a polynomial

numeric or “dummy” coding of the levels of qualitative inputs. For
example, if G is a ﬁve-level factor input, we might create Xj, j =
1, . . . , 5, such that Xj = I(G = j). Together this group of Xj repre-
sents the eﬀect of G by a set of level-dependent constants, since in

5
j=1 Xjβj, one of the Xjs is one, and the others are zero.

P
interactions between variables, for example, X3 = X1 ·

•

X2.

No matter the source of the Xj, the model is linear in the parameters.

Typically we have a set of training data (x1, y1) . . . (xN , yN ) from which
to estimate the parameters β. Each xi = (xi1, xi2, . . . , xip)T is a vector
of feature measurements for the ith case. The most popular estimation
method is least squares, in which we pick the coeﬃcients β = (β0, β1, . . . , βp)T
to minimize the residual sum of squares

RSS(β) =

N

i=1
X
N

f (xi))2

(yi −

=

i=1(cid:16)
X

yi −

β0 −

p

j=1
X

xijβj

2

.

(cid:17)

(3.2)

From a statistical point of view, this criterion is reasonable if the training
observations (xi, yi) represent independent random draws from their popu-
lation. Even if the xi’s were not drawn randomly, the criterion is still valid
if the yi’s are conditionally independent given the inputs xi. Figure 3.1
illustrates the geometry of least-squares ﬁtting in the IRp+1-dimensional

3.2 Linear Regression Models and Least Squares

45

Y

•
•
•
•
•
•

•

•
•

•
•

• •
• •
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•

•
• •
•
•
•

•
•

•
•

•
•

•

•

•

•

•

•

•
•

•

•
•
•
•
•
•

•

•
•
•
•

•
•
•

•
•

•

X2

X1

FIGURE 3.1. Linear least squares ﬁtting with X
function of X that minimizes the sum of squared residuals from Y .

∈

IR2. We seek the linear

space occupied by the pairs (X, Y ). Note that (3.2) makes no assumptions
about the validity of model (3.1); it simply ﬁnds the best linear ﬁt to the
data. Least squares ﬁtting is intuitively satisfying no matter how the data
arise; the criterion measures the average lack of ﬁt.
How do we minimize (3.2)? Denote by X the N

(p + 1) matrix with
each row an input vector (with a 1 in the ﬁrst position), and similarly let
y be the N -vector of outputs in the training set. Then we can write the
residual sum-of-squares as

×

RSS(β) = (y

Xβ)T (y

Xβ).

−

−

(3.3)

This is a quadratic function in the p + 1 parameters. Diﬀerentiating with
respect to β we obtain

2XT (y

=

∂RSS
∂β
∂2RSS
∂β∂βT = 2XT X.

−

Xβ)

−

(3.4)

Assuming (for the moment) that X has full column rank, and hence XT X
is positive deﬁnite, we set the ﬁrst derivative to zero

to obtain the unique solution

XT (y

−

Xβ) = 0

ˆβ = (XT X)−1XT y.

(3.5)

(3.6)

46

3. Linear Methods for Regression

y

ˆy

x2

x1

FIGURE 3.2. The N -dimensional geometry of least squares regression with two
predictors. The outcome vector y is orthogonally projected onto the hyperplane
spanned by the input vectors x1 and x2. The projection ˆy represents the vector
of the least squares predictions

The predicted values at an input vector x0 are given by ˆf (x0) = (1 : x0)T ˆβ;
the ﬁtted values at the training inputs are

ˆy = X ˆβ = X(XT X)−1XT y,

(3.7)

where ˆyi = ˆf (xi). The matrix H = X(XT X)−1XT appearing in equation
(3.7) is sometimes called the “hat” matrix because it puts the hat on y.

Figure 3.2 shows a diﬀerent geometrical representation of the least squares
estimate, this time in IRN . We denote the column vectors of X by x0, x1, . . . , xp,
with x0 ≡
1. For much of what follows, this ﬁrst column is treated like any
other. These vectors span a subspace of IRN , also referred to as the column
2 by choosing ˆβ so that the
space of X. We minimize RSS(β) =
y
k
k
ˆy is orthogonal to this subspace. This orthogonality is
residual vector y
expressed in (3.5), and the resulting estimate ˆy is hence the orthogonal pro-
jection of y onto this subspace. The hat matrix H computes the orthogonal
projection, and hence it is also known as a projection matrix.

Xβ

−

−

It might happen that the columns of X are not linearly independent, so
that X is not of full rank. This would occur, for example, if two of the
inputs were perfectly correlated, (e.g., x2 = 3x1). Then XT X is singular
and the least squares coeﬃcients ˆβ are not uniquely deﬁned. However,
the ﬁtted values ˆy = X ˆβ are still the projection of y onto the column
space of X; there is just more than one way to express that projection
in terms of the column vectors of X. The non-full-rank case occurs most
often when one or more qualitative inputs are coded in a redundant fashion.
There is usually a natural way to resolve the non-unique representation,
by recoding and/or dropping redundant columns in X. Most regression
software packages detect these redundancies and automatically implement

3.2 Linear Regression Models and Least Squares

47

some strategy for removing them. Rank deﬁciencies can also occur in signal
and image analysis, where the number of inputs p can exceed the number
of training cases N . In this case, the features are typically reduced by
ﬁltering or else the ﬁtting is controlled by regularization (Section 5.2.3 and
Chapter 18).

Up to now we have made minimal assumptions about the true distribu-
tion of the data. In order to pin down the sampling properties of ˆβ, we now
assume that the observations yi are uncorrelated and have constant vari-
ance σ2, and that the xi are ﬁxed (non random). The variance–covariance
matrix of the least squares parameter estimates is easily derived from (3.6)
and is given by

Var( ˆβ) = (XT X)−1σ2.

(3.8)

Typically one estimates the variance σ2 by

ˆσ2 =

1
p

N

−

N

1

−

i=1
X

ˆyi)2.

(yi −

The N
−
estimate of σ2: E(ˆσ2) = σ2.

−

p

1 rather than N in the denominator makes ˆσ2 an unbiased

To draw inferences about the parameters and the model, additional as-
sumptions are needed. We now assume that (3.1) is the correct model for
the mean; that is, the conditional expectation of Y is linear in X1, . . . , Xp.
We also assume that the deviations of Y around its expectation are additive
and Gaussian. Hence

Y = E(Y

|

X1, . . . , Xp) + ε

p

= β0 +

Xjβj + ε,

(3.9)

j=1
X
where the error ε is a Gaussian random variable with expectation zero and
variance σ2, written ε

N (0, σ2).

Under (3.9), it is easy to show that

∼

ˆβ

∼

N (β, (XT X)−1σ2).

(3.10)

This is a multivariate normal distribution with mean vector and variance–
covariance matrix as shown. Also

(N

p

−

−

1)ˆσ2

∼

σ2χ2

N −p−1,

(3.11)

1 degrees of freedom. In addition ˆβ
a chi-squared distribution with N
p
−
and ˆσ2 are statistically independent. We use these distributional properties
to form tests of hypothesis and conﬁdence intervals for the parameters βj.

−

48

3. Linear Methods for Regression

s
e
i
t
i
l
i

b
a
b
o
r
P

l
i

a
T

6
0
.
0

5
0
.
0

4
0
.
0

3
0
.
0

2
0
.
0

1
0
.
0

t30
t100
normal

2.0

2.2

2.4

Z

2.6

2.8

3.0

FIGURE 3.3. The tail probabilities Pr(
> z) for three distributions, t30, t100
|
and standard normal. Shown are the appropriate quantiles for testing signiﬁcance
at the p = 0.05 and 0.01 levels. The diﬀerence between t and the standard normal
becomes negligible for N bigger than about 100.

Z

|

To test the hypothesis that a particular coeﬃcient βj = 0, we form the

standardized coeﬃcient or Z-score

zj =

ˆβj
ˆσ√vj

,

(3.12)

where vj is the jth diagonal element of (XT X)−1. Under the null hypothesis
1
that βj = 0, zj is distributed as tN −p−1 (a t distribution with N
degrees of freedom), and hence a large (absolute) value of zj will lead to
rejection of this null hypothesis. If ˆσ is replaced by a known value σ, then
zj would have a standard normal distribution. The diﬀerence between the
tail quantiles of a t-distribution and a standard normal become negligible
as the sample size increases, and so we typically use the normal quantiles
(see Figure 3.3).

−

−

p

Often we need to test for the signiﬁcance of groups of coeﬃcients simul-
taneously. For example, to test if a categorical variable with k levels can
be excluded from a model, we need to test whether the coeﬃcients of the
dummy variables used to represent the levels can all be set to zero. Here
we use the F statistic,

F =

(RSS0 −

RSS1/(N

p0)

RSS1)/(p1 −
1)
−

p1 −

,

(3.13)

where RSS1 is the residual sum-of-squares for the least squares ﬁt of the big-
ger model with p1 +1 parameters, and RSS0 the same for the nested smaller
p0 parameters constrained to be
model with p0 + 1 parameters, having p1 −

 
3.2 Linear Regression Models and Least Squares

49

zero. The F statistic measures the change in residual sum-of-squares per
additional parameter in the bigger model, and it is normalized by an esti-
mate of σ2. Under the Gaussian assumptions, and the null hypothesis that
the smaller model is correct, the F statistic will have a Fp1−p0,N −p1−1 dis-
tribution. It can be shown (Exercise 3.1) that the zj in (3.12) are equivalent
to the F statistic for dropping the single coeﬃcient βj from the model. For
large N , the quantiles of Fp1−p0,N −p1−1 approach those of χ2
p0).
p1−p0/(p1 −
2α conﬁdence interval

Similarly, we can isolate βj in (3.10) to obtain a 1

−

for βj:

( ˆβj −

z(1−α)v

1
2

j ˆσ, ˆβj + z(1−α)v

1
2

j ˆσ).

(3.14)

Here z(1−α) is the 1

−

α percentile of the normal distribution:

z(1−0.025) = 1.96,
z(1−.05)

= 1.645, etc.

Hence the standard practice of reporting ˆβ
se( ˆβ) amounts to an ap-
proximate 95% conﬁdence interval. Even if the Gaussian error assumption
does not hold, this interval will be approximately correct, with its coverage
approaching 1

2α as the sample size N

±

2

·

.

In a similar fashion we can obtain an approximate conﬁdence set for the

→ ∞

−

entire parameter vector β, namely

( ˆβ

Cβ =

β
{
(1−α) is the 1

|

β)T XT X( ˆβ

β)

−

≤

(1−α)

ˆσ2χ2

p+1

,
}

−

(3.15)

−

where χ2
α percentile of the chi-squared distribution on ℓ
ℓ
(1−0.1) = 9.2. This
degrees of freedom: for example, χ2
5
conﬁdence set for β generates a corresponding conﬁdence set for the true
function f (x) = xT β, namely
(Exercise 3.2; see also Fig-
β
|
ure 5.4 in Section 5.2.2 for examples of conﬁdence bands for functions).

(1−0.05) = 11.1, χ2
5

xT β
{

Cβ}

∈

3.2.1 Example: Prostate Cancer

The data for this example come from a study by Stamey et al. (1989). They
examined the correlation between the level of prostate-speciﬁc antigen and
a number of clinical measures in men who were about to receive a radical
prostatectomy. The variables are log cancer volume (lcavol), log prostate
weight (lweight), age, log of the amount of benign prostatic hyperplasia
(lbph), seminal vesicle invasion (svi), log of capsular penetration (lcp),
Gleason score (gleason), and percent of Gleason scores 4 or 5 (pgg45).
The correlation matrix of the predictors given in Table 3.1 shows many
strong correlations. Figure 1.1 (page 3) of Chapter 1 is a scatterplot matrix
showing every pairwise plot between the variables. We see that svi is a
binary variable, and gleason is an ordered categorical variable. We see, for

50

3. Linear Methods for Regression

TABLE 3.1. Correlations of predictors in the prostate cancer data.

lweight
age
lbph
svi
lcp
gleason
pgg45

lcavol
0.300
0.286
0.063
0.593
0.692
0.426
0.483

lweight

age

lbph

svi

lcp

gleason

0.317
0.437
0.181
0.157
0.024
0.074

0.287
0.129
0.173
0.366
0.276

0.139
0.089
0.033
0.030

−
−

−

0.671
0.307
0.481

0.476
0.663

0.757

TABLE 3.2. Linear model ﬁt to the prostate cancer data. The Z score is the
coeﬃcient divided by its standard error (3.12). Roughly a Z score larger than two
in absolute value is signiﬁcantly nonzero at the p = 0.05 level.

Term Coeﬃcient
2.46
0.68
0.26
0.14
0.21
0.31
0.29
0.02
0.27

Intercept
lcavol
lweight
age
lbph
svi
lcp
gleason
pgg45

−
−

−

Std. Error Z Score
27.60
5.37
2.75
1.40
2.06
2.47
1.87
0.15
1.74

0.09
0.13
0.10
0.10
0.10
0.12
0.15
0.15
0.15

−
−

−

example, that both lcavol and lcp show a strong relationship with the
response lpsa, and with each other. We need to ﬁt the eﬀects jointly to
untangle the relationships between the predictors and the response.

We ﬁt a linear model to the log of prostate-speciﬁc antigen, lpsa, after
ﬁrst standardizing the predictors to have unit variance. We randomly split
the dataset into a training set of size 67 and a test set of size 30. We ap-
plied least squares estimation to the training set, producing the estimates,
standard errors and Z-scores shown in Table 3.2. The Z-scores are deﬁned
in (3.12), and measure the eﬀect of dropping that variable from the model.
A Z-score greater than 2 in absolute value is approximately signiﬁcant at
the 5% level. (For our example, we have nine parameters, and the 0.025 tail
2.002!) The predictor lcavol shows
quantiles of the t67−9 distribution are
the strongest eﬀect, with lweight and svi also strong. Notice that lcp is
not signiﬁcant, once lcavol is in the model (when used in a model without
lcavol, lcp is strongly signiﬁcant). We can also test for the exclusion of
a number of terms at once, using the F -statistic (3.13). For example, we
consider dropping all the non-signiﬁcant terms in Table 3.2, namely age,

±

3.2 Linear Regression Models and Least Squares

51

lcp, gleason, and pgg45. We get

F =

(32.81

29.43)/(9
9)

29.43/(67

−

−

5)

−

= 1.67,

(3.16)

which has a p-value of 0.17 (Pr(F4,58 > 1.67) = 0.17), and hence is not
signiﬁcant.

The mean prediction error on the test data is 0.521. In contrast, predic-
tion using the mean training value of lpsa has a test error of 1.057, which
is called the “base error rate.” Hence the linear model reduces the base
error rate by about 50%. We will return to this example later to compare
various selection and shrinkage methods.

3.2.2 The Gauss–Markov Theorem

One of the most famous results in statistics asserts that the least squares
estimates of the parameters β have the smallest variance among all linear
unbiased estimates. We will make this precise here, and also make clear
that the restriction to unbiased estimates is not necessarily a wise one. This
observation will lead us to consider biased estimates such as ridge regression
later in the chapter. We focus on estimation of any linear combination of
the parameters θ = aT β; for example, predictions f (x0) = xT
0 β are of this
form. The least squares estimate of aT β is

ˆθ = aT ˆβ = aT (XT X)−1XT y.

(3.17)

Considering X to be ﬁxed, this is a linear function cT
0 y of the response
vector y. If we assume that the linear model is correct, aT ˆβ is unbiased
since

E(aT ˆβ) = E(aT (XT X)−1XT y)

= aT (XT X)−1XT Xβ
= aT β.

(3.18)

The Gauss–Markov theorem states that if we have any other linear estima-
tor ˜θ = cT y that is unbiased for aT β, that is, E(cT y) = aT β, then

Var(aT ˆβ)

≤

Var(cT y).

(3.19)

The proof (Exercise 3.3) uses the triangle inequality. For simplicity we have
stated the result in terms of estimation of a single parameter aT β, but with
a few more deﬁnitions one can state it in terms of the entire parameter
vector β (Exercise 3.3).

Consider the mean squared error of an estimator ˜θ in estimating θ:

MSE(˜θ) = E(˜θ

θ)2

−
= Var(˜θ) + [E(˜θ)

θ]2.

−

(3.20)

52

3. Linear Methods for Regression

The ﬁrst term is the variance, while the second term is the squared bias.
The Gauss-Markov theorem implies that the least squares estimator has the
smallest mean squared error of all linear estimators with no bias. However,
there may well exist a biased estimator with smaller mean squared error.
Such an estimator would trade a little bias for a larger reduction in variance.
Biased estimates are commonly used. Any method that shrinks or sets to
zero some of the least squares coeﬃcients may result in a biased estimate.
We discuss many examples, including variable subset selection and ridge
regression, later in this chapter. From a more pragmatic point of view, most
models are distortions of the truth, and hence are biased; picking the right
model amounts to creating the right balance between bias and variance.
We go into these issues in more detail in Chapter 7.

Mean squared error is intimately related to prediction accuracy, as dis-
cussed in Chapter 2. Consider the prediction of the new response at input
x0,

Then the expected prediction error of an estimate ˜f (x0) = xT
0

˜β is

Y0 = f (x0) + ε0.

E(Y0 −

˜f (x0))2 = σ2 + E(xT
0

˜β

f (x0))2

= σ2 + MSE( ˜f (x0)).

−

(3.21)

(3.22)

Therefore, expected prediction error and mean squared error diﬀer only by
the constant σ2, representing the variance of the new observation y0.

3.2.3 Multiple Regression from Simple Univariate Regression

The linear model (3.1) with p > 1 inputs is called the multiple linear
regression model. The least squares estimates (3.6) for this model are best
understood in terms of the estimates for the univariate (p = 1) linear
model, as we indicate in this section.

Suppose ﬁrst that we have a univariate model with no intercept, that is,

Y = Xβ + ε.

(3.23)

The least squares estimate and residuals are

ˆβ =

,

N
1 xiyi
N
1 x2
i
xi ˆβ.

P
ri = yi −
P
In convenient vector notation, we let y = (y1, . . . , yN )T , x = (x1, . . . , xN )T
and deﬁne

(3.24)

x, y

h

i

N

=

xiyi,

i=1
X
= xT y,

(3.25)

3.2 Linear Regression Models and Least Squares

53

the inner product between x and y1. Then we can write

ˆβ = h
h
r = y

x, y
x, x

,

i
i
x ˆβ.

−

(3.26)

As we will see, this simple univariate regression provides the building block
for multiple linear regression. Suppose next that the inputs x1, x2, . . . , xp
(the columns of the data matrix X) are orthogonal; that is
= 0
= k. Then it is easy to check that the multiple least squares esti-
for all j
mates ˆβj are equal to
—the univariate estimates. In other
words, when the inputs are orthogonal, they have no eﬀect on each other’s
parameter estimates in the model.

xj, xki

xj, xji

xj, y

/
h

i

h

h

Orthogonal inputs occur most often with balanced, designed experiments
(where orthogonality is enforced), but almost never with observational
data. Hence we will have to orthogonalize them in order to carry this idea
further. Suppose next that we have an intercept and a single input x. Then
the least squares coeﬃcient of x has the form

x

¯x1, y

ˆβ1 =

i
¯x1
i
i xi/N , and 1 = x0, the vector of N ones. We can view the
where ¯x =
estimate (3.27) as the result of two applications of the simple regression
(3.26). The steps are:

−
¯x1, x

h
−

(3.27)

P

−

x

h

,

1. regress x on 1 to produce the residual z = x

¯x1;

−

2. regress y on the residual z to give the coeﬃcient ˆβ1.

In this procedure, “regress b on a” means a simple univariate regression of b
on a with no intercept, producing coeﬃcient ˆγ =
and residual
vector b
ˆγa. We say that b is adjusted for a, or is “orthogonalized” with
respect to a.

a, b

a, a

/
h

−

i

i

h

Step 1 orthogonalizes x with respect to x0 = 1. Step 2 is just a simple
univariate regression, using the orthogonal predictors 1 and z. Figure 3.4
shows this process for two general inputs x1 and x2. The orthogonalization
does not change the subspace spanned by x1 and x2, it simply produces an
orthogonal basis for representing it.

This recipe generalizes to the case of p inputs, as shown in Algorithm 3.1.
Note that the inputs z0, . . . , zj−1 in step 2 are orthogonal, hence the simple
regression coeﬃcients computed there are in fact also the multiple regres-
sion coeﬃcients.

1The inner-product notation is suggestive of generalizations of linear regression to

diﬀerent metric spaces, as well as to probability spaces.

6
54

3. Linear Methods for Regression

y

ˆy

x2

zzzzz

x1

FIGURE 3.4. Least squares regression by orthogonalization of the inputs. The
vector x2 is regressed on the vector x1, leaving the residual vector z. The regres-
sion of y on z gives the multiple regression coeﬃcient of x2. Adding together the
projections of y on each of x1 and z gives the least squares ﬁt ˆy.

Algorithm 3.1 Regression by Successive Orthogonalization.

1. Initialize z0 = x0 = 1.

2. For j = 1, 2, . . . , p

Regress xj on z0, z1, . . . , , zj−1 to produce coeﬃcients ˆγℓj =
1 and residual vector zj =

, ℓ = 0, . . . , j

−

zℓ, xji
h
xj −

zℓ, zℓi
/
h
j−1
k=0 ˆγkjzk.

3. Regress y on the residual zp to give the estimate ˆβp.

P

The result of this algorithm is

.

≤

(3.28)

ˆβp = h
h

zp, y
i
zp, zpi
Re-arranging the residual in step 2, we can see that each of the xj is a linear
combination of the zk, k
j. Since the zj are all orthogonal, they form
a basis for the column space of X, and hence the least squares projection
onto this subspace is ˆy. Since zp alone involves xp (with coeﬃcient 1), we
see that the coeﬃcient (3.28) is indeed the multiple regression coeﬃcient of
y on xp. This key result exposes the eﬀect of correlated inputs in multiple
regression. Note also that by rearranging the xj, any one of them could
be in the last position, and a similar results holds. Hence stated more
generally, we have shown that the jth multiple regression coeﬃcient is the
univariate regression coeﬃcient of y on xj·012...(j−1)(j+1)...,p, the residual
after regressing xj on x0, x1, . . . , xj−1, xj+1, . . . , xp:

3.2 Linear Regression Models and Least Squares

55

The multiple regression coeﬃcient ˆβj represents the additional
contribution of xj on y, after xj has been adjusted for x0, x1, . . . , xj−1,
xj+1, . . . , xp.

If xp is highly correlated with some of the other xk’s, the residual vector
zp will be close to zero, and from (3.28) the coeﬃcient ˆβp will be very
unstable. This will be true for all the variables in the correlated set. In
such situations, we might have all the Z-scores (as in Table 3.2) be small—
any one of the set can be deleted—yet we cannot delete them all. From
(3.28) we also obtain an alternate formula for the variance estimates (3.8),

Var( ˆβp) =

σ2
zp, zpi
In other words, the precision with which we can estimate ˆβp depends on
the length of the residual vector zp; this represents how much of xp is
unexplained by the other xk’s.

σ2
2 .
zpk
k

(3.29)

=

h

Algorithm 3.1 is known as the Gram–Schmidt procedure for multiple
regression, and is also a useful numerical strategy for computing the esti-
mates. We can obtain from it not just ˆβp, but also the entire multiple least
squares ﬁt, as shown in Exercise 3.4.

We can represent step 2 of Algorithm 3.1 in matrix form:

X = ZΓ,

(3.30)

where Z has as columns the zj (in order), and Γ is the upper triangular ma-
trix with entries ˆγkj. Introducing the diagonal matrix D with jth diagonal
entry Djj =

, we get

zjk
k

X = ZD−1DΓ
= QR,

(3.31)

(p + 1) orthogonal

the so-called QR decomposition of X. Here Q is an N
matrix, QT Q = I, and R is a (p + 1)

×

(p + 1) upper triangular matrix.

×
The QR decomposition represents a convenient orthogonal basis for the
column space of X. It is easy to see, for example, that the least squares
solution is given by

ˆβ = R−1QT y,
ˆy = QQT y.

(3.32)

(3.33)

Equation (3.32) is easy to solve because R is upper triangular
(Exercise 3.4).

56

3. Linear Methods for Regression

3.2.4 Multiple Outputs

Suppose we have multiple outputs Y1, Y2, . . . , YK that we wish to predict
from our inputs X0, X1, X2, . . . , Xp. We assume a linear model for each
output

p

Yk = β0k +

Xjβjk + εk

j=1
X

= fk(X) + εk.

With N training cases we can write the model in matrix notation

Y = XB + E.

(3.34)

(3.35)

(3.36)

K response matrix, with ik entry yik, X is the N

(p+1)
K matrix of parameters and E is the
K matrix of errors. A straightforward generalization of the univariate

Here Y is the N
×
input matrix, B is the (p + 1)
N
loss function (3.2) is

×

×

×

K

N

RSS(B) =

Xk=1
= tr[(Y

i=1
X

−

fk(xi))2

(yik −
XB)T (Y

XB)].

−

The least squares estimates have exactly the same form as before

ˆB = (XT X)−1XT Y.

(3.37)

(3.38)

(3.39)

Hence the coeﬃcients for the kth outcome are just the least squares es-
timates in the regression of yk on x0, x1, . . . , xp. Multiple outputs do not
aﬀect one another’s least squares estimates.

If the errors ε = (ε1, . . . , εK ) in (3.34) are correlated, then it might seem
appropriate to modify (3.37) in favor of a multivariate version. Speciﬁcally,
suppose Cov(ε) = Σ, then the multivariate weighted criterion

RSS(B; Σ) =

N

i=1
X

(yi −

f (xi))T Σ−1(yi −

f (xi))

(3.40)

arises naturally from multivariate Gaussian theory. Here f (x) is the vector
function (f1(x), . . . , fK (x))T , and yi the vector of K responses for obser-
vation i. However, it can be shown that again the solution is given by
(3.39); K separate regressions that ignore the correlations (Exercise 3.11).
If the Σi vary among observations, then this is no longer the case, and the
solution for B no longer decouples.

In Section 3.7 we pursue the multiple outcome problem, and consider

situations where it does pay to combine the regressions.

3.3 Subset Selection

57

3.3 Subset Selection

There are two reasons why we are often not satisﬁed with the least squares
estimates (3.6).

•

•

The ﬁrst is prediction accuracy: the least squares estimates often have
low bias but large variance. Prediction accuracy can sometimes be
improved by shrinking or setting some coeﬃcients to zero. By doing
so we sacriﬁce a little bit of bias to reduce the variance of the predicted
values, and hence may improve the overall prediction accuracy.

The second reason is interpretation. With a large number of predic-
tors, we often would like to determine a smaller subset that exhibit
the strongest eﬀects. In order to get the “big picture,” we are willing
to sacriﬁce some of the small details.

In this section we describe a number of approaches to variable subset selec-
tion with linear regression. In later sections we discuss shrinkage and hybrid
approaches for controlling variance, as well as other dimension-reduction
strategies. These all fall under the general heading model selection. Model
selection is not restricted to linear models; Chapter 7 covers this topic in
some detail.

With subset selection we retain only a subset of the variables, and elim-
inate the rest from the model. Least squares regression is used to estimate
the coeﬃcients of the inputs that are retained. There are a number of dif-
ferent strategies for choosing the subset.

3.3.1 Best-Subset Selection

}

∈ {

0, 1, 2, . . . , p

Best subset regression ﬁnds for each k
the subset of size k
that gives smallest residual sum of squares (3.2). An eﬃcient algorithm—
the leaps and bounds procedure (Furnival and Wilson, 1974)—makes this
feasible for p as large as 30 or 40. Figure 3.5 shows all the subset models
for the prostate cancer example. The lower boundary represents the models
that are eligible for selection by the best-subsets approach. Note that the
best subset of size 2, for example, need not include the variable that was
in the best subset of size 1 (for this example all the subsets are nested).
The best-subset curve (red lower boundary in Figure 3.5) is necessarily
decreasing, so cannot be used to select the subset size k. The question of
how to choose k involves the tradeoﬀ between bias and variance, along with
the more subjective desire for parsimony. There are a number of criteria
that one may use; typically we choose the smallest model that minimizes
an estimate of the expected prediction error.

Many of the other approaches that we discuss in this chapter are similar,
in that they use the training data to produce a sequence of models varying
in complexity and indexed by a single parameter. In the next section we use

58

3. Linear Methods for Regression

••
•
•
••
•

•
•

•
•

•••••••••
•••••
•••
•
••••••
•

••••••
•••••••••
••••••••••••••••••••••••••••••••••

•

•
•

s
e
r
a
u
q
S
−
o
−
m
u
S

f

l

i

a
u
d
s
e
R

0
0
1

0
8

0
6

0
4

0
2

0

••
•••••••

•••••••••••••••••••••••••••••••••••••••••••••••••••••••••

•

••
•••••••••
••••••••••••••••••••••••••••••••••

•

••
•••••
•••••••••••••••••••
•

•
•••••••
•

•
•

0

1

2

3

4

5

6

7

8

Subset Size k

FIGURE 3.5. All possible subset models for the prostate cancer example. At
each subset size is shown the residual sum-of-squares for each model of that size.

cross-validation to estimate prediction error and select k; the AIC criterion
is a popular alternative. We defer more detailed discussion of these and
other approaches to Chapter 7.

3.3.2 Forward- and Backward-Stepwise Selection

Rather than search through all possible subsets (which becomes infeasible
for p much larger than 40), we can seek a good path through them. Forward-
stepwise selection starts with the intercept, and then sequentially adds into
the model the predictor that most improves the ﬁt. With many candidate
predictors, this might seem like a lot of computation; however, clever up-
dating algorithms can exploit the QR decomposition for the current ﬁt to
rapidly establish the next candidate (Exercise 3.9). Like best-subset re-
gression, forward stepwise produces a sequence of models indexed by k, the
subset size, which must be determined.

Forward-stepwise selection is a greedy algorithm, producing a nested se-
quence of models. In this sense it might seem sub-optimal compared to
best-subset selection. However, there are several reasons why it might be
preferred:

 
3.3 Subset Selection

59

•

•

Computational; for large p we cannot compute the best subset se-
quence, but we can always compute the forward stepwise sequence
(even when p

N ).

≫

Statistical; a price is paid in variance for selecting the best subset
of each size; forward stepwise is a more constrained search, and will
have lower variance, but perhaps more bias.

Best Subset
Forward Stepwise
Backward Stepwise
Forward Stagewise

2

|
|

β

−

)
k
(
ˆβ

|
|

E

5
9
.
0

0
9
.
0

5
8
.
0

0
8
.
0

5
7
.
0

0
7
.
0

5
6
.
0

0

5

10

15

20

25

30

Subset Size k

FIGURE 3.6. Comparison of four subset-selection techniques on a simulated lin-
ear regression problem Y = X T β + ε. There are N = 300 observations on p = 31
standard Gaussian variables, with pairwise correlations all equal to 0.85. For 10 of
the variables, the coeﬃcients are drawn at random from a N (0, 0.4) distribution;
the rest are zero. The noise ε
N (0, 6.25), resulting in a signal-to-noise ratio of
∼
0.64. Results are averaged over 50 simulations. Shown is the mean-squared error
of the estimated coeﬃcient ˆβ(k) at each step from the true β.

Backward-stepwise selection starts with the full model, and sequentially
deletes the predictor that has the least impact on the ﬁt. The candidate for
dropping is the variable with the smallest Z-score (Exercise 3.10). Backward
selection can only be used when N > p, while forward stepwise can always
be used.

Figure 3.6 shows the results of a small simulation study to compare
best-subset regression with the simpler alternatives forward and backward
selection. Their performance is very similar, as is often the case. Included in
the ﬁgure is forward stagewise regression (next section), which takes longer
to reach minimum error.

60

3. Linear Methods for Regression

On the prostate cancer example, best-subset, forward and backward se-

lection all gave exactly the same sequence of terms.

Some software packages implement hybrid stepwise-selection strategies
that consider both forward and backward moves at each step, and select
the “best” of the two. For example in the R package the step function uses
the AIC criterion for weighing the choices, which takes proper account of
the number of parameters ﬁt; at each step an add or drop will be performed
that minimizes the AIC score.

Other more traditional packages base the selection on F -statistics, adding
“signiﬁcant” terms, and dropping “non-signiﬁcant” terms. These are out
of fashion, since they do not take proper account of the multiple testing
issues. It is also tempting after a model search to print out a summary of
the chosen model, such as in Table 3.2; however, the standard errors are
not valid, since they do not account for the search process. The bootstrap
(Section 8.2) can be useful in such settings.

Finally, we note that often variables come in groups (such as the dummy
variables that code a multi-level categorical predictor). Smart stepwise pro-
cedures (such as step in R) will add or drop whole groups at a time, taking
proper account of their degrees-of-freedom.

3.3.3 Forward-Stagewise Regression

Forward-stagewise regression (FS) is even more constrained than forward-
stepwise regression. It starts like forward-stepwise regression, with an in-
tercept equal to ¯y, and centered predictors with coeﬃcients initially all 0.
At each step the algorithm identiﬁes the variable most correlated with the
current residual. It then computes the simple linear regression coeﬃcient
of the residual on this chosen variable, and then adds it to the current co-
eﬃcient for that variable. This is continued till none of the variables have
correlation with the residuals—i.e. the least-squares ﬁt when N > p.

Unlike forward-stepwise regression, none of the other variables are ad-
justed when a term is added to the model. As a consequence, forward
stagewise can take many more than p steps to reach the least squares ﬁt,
and historically has been dismissed as being ineﬃcient. It turns out that
this “slow ﬁtting” can pay dividends in high-dimensional problems. We
see in Section 3.8.1 that both forward stagewise and a variant which is
slowed down even further are quite competitive, especially in very high-
dimensional problems.

Forward-stagewise regression is included in Figure 3.6. In this example it
takes over 1000 steps to get all the correlations below 10−4. For subset size
k, we plotted the error for the last step for which there where k nonzero
coeﬃcients. Although it catches up with the best ﬁt, it takes longer to
do so.

3.4 Shrinkage Methods

61

3.3.4 Prostate Cancer Data Example (Continued)

Table 3.3 shows the coeﬃcients from a number of diﬀerent selection and
shrinkage methods. They are best-subset selection using an all-subsets search,
ridge regression, the lasso, principal components regression and partial least
squares. Each method has a complexity parameter, and this was chosen to
minimize an estimate of prediction error based on tenfold cross-validation;
full details are given in Section 7.10. Brieﬂy, cross-validation works by divid-
ing the training data randomly into ten equal parts. The learning method
is ﬁt—for a range of values of the complexity parameter—to nine-tenths of
the data, and the prediction error is computed on the remaining one-tenth.
This is done in turn for each one-tenth of the data, and the ten prediction
error estimates are averaged. From this we obtain an estimated prediction
error curve as a function of the complexity parameter.

Note that we have already divided these data into a training set of size
67 and a test set of size 30. Cross-validation is applied to the training set,
since selecting the shrinkage parameter is part of the training process. The
test set is there to judge the performance of the selected model.

The estimated prediction error curves are shown in Figure 3.7. Many of
the curves are very ﬂat over large ranges near their minimum. Included
are estimated standard error bands for each estimated error rate, based on
the ten error estimates computed by cross-validation. We have used the
“one-standard-error” rule—we pick the most parsimonious model within
one standard error of the minimum (Section 7.10, page 244). Such a rule
acknowledges the fact that the tradeoﬀ curve is estimated with error, and
hence takes a conservative approach.

Best-subset selection chose to use the two predictors lcvol and lweight.
The last two lines of the table give the average prediction error (and its
estimated standard error) over the test set.

3.4 Shrinkage Methods

By retaining a subset of the predictors and discarding the rest, subset selec-
tion produces a model that is interpretable and has possibly lower predic-
tion error than the full model. However, because it is a discrete process—
variables are either retained or discarded—it often exhibits high variance,
and so doesn’t reduce the prediction error of the full model. Shrinkage
methods are more continuous, and don’t suﬀer as much from high
variability.

3.4.1 Ridge Regression

Ridge regression shrinks the regression coeﬃcients by imposing a penalty
on their size. The ridge coeﬃcients minimize a penalized residual sum of

62

3. Linear Methods for Regression

All Subsets

Ridge Regression

8
.
1

6
.
1

4
.
1

2
.
1

0
.
1

8
.
0

6
.
0

8
.

1

6

.

1

4
1

.

2

.

1

0

.

1

8

.

0

6
0

.

8
1

.

6

.

1

4
1

.

2

.

1

0

.

1

8

.

0

6
0

.

r
o
r
r

E
V
C

r
o
r
r

E
V
C

r
o
r
r

E
V
C

•

0

•

•

•

•

•

•

2

•

4

•

6

•

•

8

Subset Size

Lasso

•

•

•

•

•

•

•

•

0

•

8
.
1

6
.
1

4
.
1

2
.
1

0
.
1

8
.
0

6
.
0

8
.

1

6

.

1

4
1

.

2

.

1

0

.

1

8

.

0

6
0

.

r
o
r
r

E
V
C

r
o
r
r

E
V
C

0.0

0.2

0.4

0.6

0.8

1.0

0

•

•

•

2

•

•

4

•

6

•

•

8

Degrees of Freedom

Principal Components Regression

•

•

2

•

•

•

4

•

6

•

•

8

Shrinkage Factor s

Number of Directions

Partial Least Squares

•

0

•

•

•

2

•

4

•

•

6

•

•

8

Number of  Directions

FIGURE 3.7. Estimated prediction error curves and their standard errors for
the various selection and shrinkage methods. Each curve is plotted as a function
of the corresponding complexity parameter for that method. The horizontal axis
has been chosen so that the model complexity increases as we move from left to
right. The estimates of prediction error and their standard errors were obtained by
tenfold cross-validation; full details are given in Section 7.10. The least complex
model within one standard error of the best is chosen, indicated by the purple
vertical broken lines.

 
 
 
 
 
3.4 Shrinkage Methods

63

TABLE 3.3. Estimated coeﬃcients and test error results, for diﬀerent subset
and shrinkage methods applied to the prostate data. The blank entries correspond
to variables omitted.

LS Best Subset
2.477
0.740
0.316

−

Ridge
2.452
0.420
0.238
0.046
0.162
0.227
0.000
0.040
0.133
0.492
0.165

Lasso
2.468
0.533
0.169

0.002
0.094

0.479
0.164

PCR
2.497
0.543
0.289
0.152
0.214
0.315
0.051
0.232
0.056
0.449
0.105

−

−

−

−

PLS
2.452
0.419
0.344
0.026
0.220
0.243
0.079
0.011
0.084
0.528
0.152

0.492
0.143

2.465
0.680
0.263
0.141
0.210
0.305
0.288
0.021
0.267
0.521
0.179

−

−
−

Term
Intercept
lcavol
lweight
age
lbph
svi
lcp
gleason
pgg45
Test Error
Std Error

squares,

ˆβridge = argmin

N

β (cid:26)

i=1
X

(cid:0)

yi −

β0 −

p

j=1
X

xijβj

2

+ λ

(cid:1)

p

j=1
X

β2
j

.
(cid:27)

(3.41)

≥

Here λ
0 is a complexity parameter that controls the amount of shrink-
age: the larger the value of λ, the greater the amount of shrinkage. The
coeﬃcients are shrunk toward zero (and each other). The idea of penaliz-
ing by the sum-of-squares of the parameters is also used in neural networks,
where it is known as weight decay (Chapter 11).

An equivalent way to write the ridge problem is

ˆβridge = argmin

N

β

i=1(cid:16)
X
p

yi −

β0 −

p

j=1
X

xijβj

2

,

(cid:17)

(3.42)

subject to

β2
j ≤

t,

j=1
X

which makes explicit the size constraint on the parameters. There is a one-
to-one correspondence between the parameters λ in (3.41) and t in (3.42).
When there are many correlated variables in a linear regression model,
their coeﬃcients can become poorly determined and exhibit high variance.
A wildly large positive coeﬃcient on one variable can be canceled by a
similarly large negative coeﬃcient on its correlated cousin. By imposing a
size constraint on the coeﬃcients, as in (3.42), this problem is alleviated.
The ridge solutions are not equivariant under scaling of the inputs, and
so one normally standardizes the inputs before solving (3.41). In addition,

64

3. Linear Methods for Regression

notice that the intercept β0 has been left out of the penalty term. Penal-
ization of the intercept would make the procedure depend on the origin
chosen for Y ; that is, adding a constant c to each of the targets yi would
not simply result in a shift of the predictions by the same amount c. It
can be shown (Exercise 3.5) that the solution to (3.41) can be separated
into two parts, after reparametrization using centered inputs: each xij gets
N
replaced by xij −
1 yi. The remaining co-
eﬃcients get estimated by a ridge regression without intercept, using the
centered xij. Henceforth we assume that this centering has been done, so
that the input matrix X has p (rather than p + 1) columns.

¯xj. We estimate β0 by ¯y = 1
N

P

Writing the criterion in (3.41) in matrix form,

RSS(λ) = (y

Xβ)T (y

−

−

Xβ) + λβT β,

the ridge regression solutions are easily seen to be

ˆβridge = (XT X + λI)−1XT y,

(3.43)

(3.44)

×

where I is the p
p identity matrix. Notice that with the choice of quadratic
penalty βT β, the ridge regression solution is again a linear function of
y. The solution adds a positive constant to the diagonal of XT X before
inversion. This makes the problem nonsingular, even if XT X is not of full
rank, and was the main motivation for ridge regression when it was ﬁrst
introduced in statistics (Hoerl and Kennard, 1970). Traditional descriptions
of ridge regression start with deﬁnition (3.44). We choose to motivate it via
(3.41) and (3.42), as these provide insight into how it works.

Figure 3.8 shows the ridge coeﬃcient estimates for the prostate can-
cer example, plotted as functions of df(λ), the eﬀective degrees of freedom
implied by the penalty λ (deﬁned in (3.50) on page 68). In the case of or-
thonormal inputs, the ridge estimates are just a scaled version of the least
squares estimates, that is, ˆβridge = ˆβ/(1 + λ).

N (β0 + xT

Ridge regression can also be derived as the mean or mode of a poste-
rior distribution, with a suitably chosen prior distribution. In detail, sup-
i β, σ2), and the parameters βj are each distributed as
pose yi ∼
N (0, τ 2), independently of one another. Then the (negative) log-posterior
density of β, with τ 2 and σ2 assumed known, is equal to the expression
in curly braces in (3.41), with λ = σ2/τ 2 (Exercise 3.6). Thus the ridge
estimate is the mode of the posterior distribution; since the distribution is
Gaussian, it is also the posterior mean.

The singular value decomposition (SVD) of the centered input matrix X
gives us some additional insight into the nature of ridge regression. This de-
composition is extremely useful in the analysis of many statistical methods.
The SVD of the N

p matrix X has the form

×

X = UDVT .

(3.45)

3.4 Shrinkage Methods

65

•

lcavol

••

•

•

•

•

•

•

•
•
•

svi
lweight
pgg45

•

lbph

•••••••
•••••••
•••••••
•••••••

•••••••

•

gleason

•
•

•
•

•

•
•

•

•

•••••••

•

•

•

•

•

•

age

•

lcp

8

6
.
0

4
.
0

2
.
0

i

s
t
n
e
c
i
f
f
e
o
C

0
.
0

•
•
•
•
•
•
•
•

2
.
0
−

•

•
•

•
•

•

•
•

•

•
•

•
•

•
•

•

•

•
•

•
•

•
•

•

•

•
•

•
•

•
•

•

•

•
•

•
•

•
•

•

•

•
•

•
•
•
•

•

•

•
•

•
•
•
•
•

•

•
•

•
•
•
•
•

•

•
•

•
•
•
•

•

•

•

•

•
••••••
•
•
•
••••
•
••••••
••••••
••••••
••••••
••••••

0

2

4

df(λ)

6

FIGURE 3.8. Proﬁles of ridge coeﬃcients for the prostate cancer example, as
the tuning parameter λ is varied. Coeﬃcients are plotted versus df(λ), the eﬀective
degrees of freedom. A vertical line is drawn at df = 5.0, the value chosen by
cross-validation.

66

3. Linear Methods for Regression

p and p

Here U and V are N
p orthogonal matrices, with the columns
of U spanning the column space of X, and the columns of V spanning the
row space. D is a p
d2 ≥
0 called the singular values of X. If one or more values dj = 0,
dp ≥
· · · ≥
X is singular.

×
p diagonal matrix, with diagonal entries d1 ≥

×

×

Using the singular value decomposition we can write the least squares

ﬁtted vector as

X ˆβls = X(XT X)−1XT y
= UUT y,

(3.46)

after some simpliﬁcation. Note that UT y are the coordinates of y with
respect to the orthonormal basis U. Note also the similarity with (3.33);
Q and U are generally diﬀerent orthogonal bases for the column space of
X (Exercise 3.8).

Now the ridge solutions are

X ˆβridge = X(XT X + λI)−1XT y

p

= U D(D2 + λI)−1D UT y
d2
j
d2
j + λ

j y,

uT

uj

=

j=1
X

(3.47)

≤

where the uj are the columns of U. Note that since λ
j +
λ)
1. Like linear regression, ridge regression computes the coordinates of
y with respect to the orthonormal basis U. It then shrinks these coordinates
by the factors d2
j + λ). This means that a greater amount of shrinkage
is applied to the coordinates of basis vectors with smaller d2
j .

0, we have d2

j /(d2

j /(d2

≥

What does a small value of d2

j mean? The SVD of the centered matrix
X is another way of expressing the principal components of the variables
in X. The sample covariance matrix is given by S = XT X/N , and from
(3.45) we have

XT X = VD2VT ,

(3.48)

which is the eigen decomposition of XT X (and of S, up to a factor N ).
The eigenvectors vj (columns of V) are also called the principal compo-
nents (or Karhunen–Loeve) directions of X. The ﬁrst principal component
direction v1 has the property that z1 = Xv1 has the largest sample vari-
ance amongst all normalized linear combinations of the columns of X. This
sample variance is easily seen to be

Var(z1) = Var(Xv1) =

d2
1
N

,

(3.49)

and in fact z1 = Xv1 = u1d1. The derived variable z1 is called the ﬁrst
principal component of X, and hence u1 is the normalized ﬁrst principal

3.4 Shrinkage Methods

67

Largest Principal
Component

o

o

o

o

o
o

o
o

o

o

o

o
o
o

o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o
o
o

o
o

o

o

o
o
o

o

o

o

o

o
o
o

o
o

o

o

o

o

Smallest Principal
Component

o

o

o
o

o

o
o

o

o

o
o
o

o

o

4

2

2
X

0

2
-

4
-

-4

-2

0

X1

2

4

FIGURE 3.9. Principal components of some input data points. The largest prin-
cipal component is the direction that maximizes the variance of the projected data,
and the smallest principal component minimizes that variance. Ridge regression
projects y onto these components, and then shrinks the coeﬃcients of the low–
variance components more than the high-variance components.

component. Subsequent principal components zj have maximum variance
d2
j /N , subject to being orthogonal to the earlier ones. Conversely the last
principal component has minimum variance. Hence the small singular val-
ues dj correspond to directions in the column space of X having small
variance, and ridge regression shrinks these directions the most.

Figure 3.9 illustrates the principal components of some data points in
two dimensions. If we consider ﬁtting a linear surface over this domain
(the Y -axis is sticking out of the page), the conﬁguration of the data allow
us to determine its gradient more accurately in the long direction than
the short. Ridge regression protects against the potentially high variance
of gradients estimated in the short directions. The implicit assumption is
that the response will tend to vary most in the directions of high variance
of the inputs. This is often a reasonable assumption, since predictors are
often chosen for study because they vary with the response variable, but
need not hold in general.

68

3. Linear Methods for Regression

In Figure 3.7 we have plotted the estimated prediction error versus the

quantity

df(λ) = tr[X(XT X + λI)−1XT ],

= tr(Hλ)
p

=

j=1
X

d2
j
d2
j + λ

.

(3.50)

This monotone decreasing function of λ is the eﬀective degrees of freedom
of the ridge regression ﬁt. Usually in a linear-regression ﬁt with p variables,
the degrees-of-freedom of the ﬁt is p, the number of free parameters. The
idea is that although all p coeﬃcients in a ridge ﬁt will be non-zero, they
are ﬁt in a restricted fashion controlled by λ. Note that df(λ) = p when
. Of course there
λ = 0 (no regularization) and df(λ)
is always an additional one degree of freedom for the intercept, which was
removed apriori. This deﬁnition is motivated in more detail in Section 3.4.4
and Sections 7.4–7.6. In Figure 3.7 the minimum occurs at df(λ) = 5.0.
Table 3.3 shows that ridge regression reduces the test error of the full least
squares estimates by a small amount.

0 as λ

→ ∞

→

3.4.2 The Lasso

The lasso is a shrinkage method like ridge, with subtle but important dif-
ferences. The lasso estimate is deﬁned by

ˆβlasso = argmin

N

β

i=1(cid:16)
X

p

j=1
X

xijβj

2

(cid:17)

yi −

β0 −

p

subject to

βj| ≤

|

t.

j=1
X

(3.51)

Just as in ridge regression, we can re-parametrize the constant β0 by stan-
dardizing the predictors; the solution for ˆβ0 is ¯y, and thereafter we ﬁt a
model without an intercept (Exercise 3.5). In the signal processing litera-
ture, the lasso is also known as basis pursuit (Chen et al., 1998).

We can also write the lasso problem in the equivalent Lagrangian form

ˆβlasso = argmin

β (cid:26)

1
2

N

i=1
X

(cid:0)

yi −

β0 −

p

j=1
X

xijβj

2

+ λ

(cid:1)

p

j=1
X

βj|

|

.

(cid:27)

(3.52)

Notice the similarity to the ridge regression problem (3.42) or (3.41): the
. This
L2 ridge penalty
latter constraint makes the solutions nonlinear in the yi, and there is no
closed form expression as in ridge regression. Computing the lasso solution

j is replaced by the L1 lasso penalty

p
1 β2

βj|

p
1 |

P

P

3.4 Shrinkage Methods

69

is a quadratic programming problem, although we see in Section 3.4.4 that
eﬃcient algorithms are available for computing the entire path of solutions
as λ is varied, with the same computational cost as for ridge regression.
Because of the nature of the constraint, making t suﬃciently small will
cause some of the coeﬃcients to be exactly zero. Thus the lasso does a kind
(where
of continuous subset selection. If t is chosen larger than t0 =
ˆβj = ˆβls
j , the least squares estimates), then the lasso estimates are the ˆβj’s.
On the other hand, for t = t0/2 say, then the least squares coeﬃcients are
shrunk by about 50% on average. However, the nature of the shrinkage
is not obvious, and we investigate it further in Section 3.4.4 below. Like
the subset size in variable subset selection, or the penalty parameter in
ridge regression, t should be adaptively chosen to minimize an estimate of
expected prediction error.

ˆβj|

p
1 |

P

In Figure 3.7, for ease of interpretation, we have plotted the lasso pre-
ˆβj|
diction error estimates versus the standardized parameter s = t/
.
A value ˆs
0.36 was chosen by 10-fold cross-validation; this caused four
coeﬃcients to be set to zero (ﬁfth column of Table 3.3). The resulting
model has the second lowest test error, slightly lower than the full least
squares model, but the standard errors of the test error estimates (last line
of Table 3.3) are fairly large.

p
1 |

P

≈

Figure 3.10 shows the lasso coeﬃcients as the standardized tuning pa-
rameter s = t/
is varied. At s = 1.0 these are the least squares
0. This decrease is not always strictly
estimates; they decrease to 0 as s
P
monotonic, although it is in this example. A vertical line is drawn at
s = 0.36, the value chosen by cross-validation.

ˆβj|

p
1 |

→

3.4.3 Discussion: Subset Selection, Ridge Regression and the

Lasso

In this section we discuss and compare the three approaches discussed so far
for restricting the linear regression model: subset selection, ridge regression
and the lasso.

In the case of an orthonormal input matrix X the three procedures have
explicit solutions. Each method applies a simple transformation to the least
squares estimate ˆβj, as detailed in Table 3.4.

Ridge regression does a proportional shrinkage. Lasso translates each
coeﬃcient by a constant factor λ, truncating at zero. This is called “soft
thresholding,” and is used in the context of wavelet-based smoothing in Sec-
tion 5.9. Best-subset selection drops all variables with coeﬃcients smaller
than the M th largest; this is a form of “hard-thresholding.”

Back to the nonorthogonal case; some pictures help understand their re-
lationship. Figure 3.11 depicts the lasso (left) and ridge regression (right)
when there are only two parameters. The residual sum of squares has ellip-
tical contours, centered at the full least squares estimate. The constraint

70

3. Linear Methods for Regression

i

s
t
n
e
c
i
f
f
e
o
C

6
.
0

4
.
0

2
.
0

0
.
0

2
.
0
−

lcavol

svi
lweight
pgg45

lbph

gleason

age

lcp

0.0

0.2

0.4

0.6

0.8

1.0

Shrinkage Factor s

FIGURE 3.10. Proﬁles of lasso coeﬃcients, as the tuning parameter t is varied.
p
. A vertical line is drawn at s = 0.36,
Coeﬃcients are plotted versus s = t/
1 |
the value chosen by cross-validation. Compare Figure 3.8 on page 65; the lasso
proﬁles hit zero, while those for ridge do not. The proﬁles are piece-wise linear,
and so are computed only at the points displayed; see Section 3.4.4 for details.

ˆβj

P

|

3.4 Shrinkage Methods

71

TABLE 3.4. Estimators of βj in the case of orthonormal columns of X. M and λ
are constants chosen by the corresponding techniques; sign denotes the sign of its
argument (
1), and x+ denotes “positive part” of x. Below the table, estimators
are shown by broken red lines. The 45◦ line in gray shows the unrestricted estimate
for reference.

±

Estimator

Best subset (size M )

Ridge

Lasso

Formula
ˆβj ·
I(
|
ˆβj/(1 + λ)
sign( ˆβj)(

ˆβj| ≥ |

ˆβ(M )|

)

ˆβj| −

|

λ)+

Best Subset

Ridge

Lasso

| ˆβ(M )|

(0,0)

(0,0)

(0,0)

λ

2

.

b^

2

.

b^

1

1

FIGURE 3.11. Estimation picture for the lasso (left) and ridge regression
(right). Shown are contours of the error and constraint functions. The solid blue
t2, respectively,
areas are the constraint regions
β2
|
while the red ellipses are the contours of the least squares error function.

t and β2

1 + β2

2 ≤

| ≤

β1

+

|

|

b
b
b
b
72

3. Linear Methods for Regression

|

|

+

β1|

1 + β2

β2| ≤

region for ridge regression is the disk β2
t, while that for lasso is
t. Both methods ﬁnd the ﬁrst point where the
the diamond
elliptical contours hit the constraint region. Unlike the disk, the diamond
has corners; if the solution occurs at a corner, then it has one parameter
βj equal to zero. When p > 2, the diamond becomes a rhomboid, and has
many corners, ﬂat edges and faces; there are many more opportunities for
the estimated parameters to be zero.

2 ≤

We can generalize ridge regression and the lasso, and view them as Bayes

p

xijβj

2

+ λ

q

βj|

|

)

(3.53)

estimates. Consider the criterion

N

p

˜β = argmin

yi −

β0 −

β (

i=1
X

(cid:1)
0. The contours of constant value of

(cid:0)

j=1
X

j=1
X
βj|

j |

P

q are shown in Fig-

≥

for q
ure 3.12, for the case of two inputs.
βj|

|

Thinking of

q as the log-prior density for βj, these are also the equi-
contours of the prior distribution of the parameters. The value q = 0 corre-
sponds to variable subset selection, as the penalty simply counts the number
of nonzero parameters; q = 1 corresponds to the lasso, while q = 2 to ridge
regression. Notice that for q
1, the prior is not uniform in direction, but
concentrates more mass in the coordinate directions. The prior correspond-
ing to the q = 1 case is an independent double exponential (or Laplace)
/τ ) and τ = 1/λ.
distribution for each input, with density (1/2τ ) exp(
The case q = 1 (lasso) is the smallest q such that the constraint region
is convex; non-convex constraint regions make the optimization problem
more diﬃcult.

−|

≤

β

|

In this view, the lasso, ridge regression and best subset selection are
Bayes estimates with diﬀerent priors. Note, however, that they are derived
as posterior modes, that is, maximizers of the posterior. It is more common
to use the mean of the posterior as the Bayes estimate. Ridge regression is
also the posterior mean, but the lasso and best subset selection are not.

Looking again at the criterion (3.53), we might try using other values
of q besides 0, 1, or 2. Although one might consider estimating q from
the data, our experience is that it is not worth the eﬀort for the extra
(1, 2) suggest a compromise between the
variance incurred. Values of q
q is
lasso and ridge regression. Although this is the case, with q > 1,
diﬀerentiable at 0, and so does not share the ability of lasso (q = 1) for

βj|

∈

|

q = 4

q = 2

q = 1

q = 0.5

q = 0.1

FIGURE 3.12. Contours of constant value of

Pj |

βj

|

q for given values of q.

3.4 Shrinkage Methods

73

q = 1.2

α = 0.2

Lq

Elastic Net

q for q = 1.2 (left plot),
FIGURE 3.13. Contours of constant value of
and the elastic-net penalty
) for α = 0.2 (right plot). Although
−
visually very similar, the elastic-net has sharp (non-diﬀerentiable) corners, while
the q = 1.2 penalty does not.

Pj(αβ2

j +(1

Pj |

α)

βj

βj

|

|

|

setting coeﬃcients exactly to zero. Partly for this reason as well as for
computational tractability, Zou and Hastie (2005) introduced the elastic-
net penalty

p

λ

j=1
X

(cid:0)

αβ2

j + (1

α)

βj|

|

−

,

(cid:1)

(3.54)

a diﬀerent compromise between ridge and lasso. Figure 3.13 compares the
Lq penalty with q = 1.2 and the elastic-net penalty with α = 0.2; it is
hard to detect the diﬀerence by eye. The elastic-net selects variables like
the lasso, and shrinks together the coeﬃcients of correlated predictors like
ridge. It also has considerable computational advantages over the Lq penal-
ties. We discuss the elastic-net further in Section 18.4.

3.4.4 Least Angle Regression

Least angle regression (LAR) is a relative newcomer (Efron et al., 2004),
and can be viewed as a kind of “democratic” version of forward stepwise
regression (Section 3.3.2). As we will see, LAR is intimately connected
with the lasso, and in fact provides an extremely eﬃcient algorithm for
computing the entire lasso path as in Figure 3.10.

Forward stepwise regression builds a model sequentially, adding one vari-
able at a time. At each step, it identiﬁes the best variable to include in the
active set, and then updates the least squares ﬁt to include all the active
variables.

Least angle regression uses a similar strategy, but only enters “as much”
of a predictor as it deserves. At the ﬁrst step it identiﬁes the variable
most correlated with the response. Rather than ﬁt this variable completely,
LAR moves the coeﬃcient of this variable continuously toward its least-
squares value (causing its correlation with the evolving residual to decrease
in absolute value). As soon as another variable “catches up” in terms of
correlation with the residual, the process is paused. The second variable
then joins the active set, and their coeﬃcients are moved together in a way
that keeps their correlations tied and decreasing. This process is continued

74

3. Linear Methods for Regression

until all the variables are in the model, and ends at the full least-squares
ﬁt. Algorithm 3.2 provides the details. The termination condition in step 5
1, the LAR algorithm reaches a zero
requires some explanation. If p > N
residual solution after N
1 is because we have centered the
data).

−
1 steps (the

−

−

Algorithm 3.2 Least Angle Regression.

1. Standardize the predictors to have mean zero and unit norm. Start

with the residual r = y

¯y, β1, β2, . . . , βp = 0.

−

2. Find the predictor xj most correlated with r.

3. Move βj from 0 towards its least-squares coeﬃcient

, until some
other competitor xk has as much correlation with the current residual
as does xj.

xj, r

h

i

4. Move βj and βk in the direction deﬁned by their joint least squares
coeﬃcient of the current residual on (xj, xk), until some other com-
petitor xl has as much correlation with the current residual.

5. Continue in this way until all p predictors have been entered. After

min(N

−

1, p) steps, we arrive at the full least-squares solution.

Suppose

Ak is the active set of variables at the beginning of the kth
step, and let βAk be the coeﬃcient vector for these variables at this step;
there will be k
1 nonzero values, and the one just entered will be zero. If
XAk βAk is the current residual, then the direction for this step is
rk = y
XAk )−1XT
Ak

δk = (XT
Ak

(3.55)

rk.

−

−

The coeﬃcient proﬁle then evolves as βAk (α) = βAk + α
δk. Exercise 3.23
veriﬁes that the directions chosen in this fashion do what is claimed: keep
the correlations tied and decreasing. If the ﬁt vector at the beginning of
this step is ˆfk, then it evolves as ˆfk(α) = ˆfk + α
uk, where uk = XAk δk
is the new ﬁt direction. The name “least angle” arises from a geometrical
interpretation of this process; uk makes the smallest (and equal) angle
with each of the predictors in
Ak (Exercise 3.24). Figure 3.14 shows the
absolute correlations decreasing and joining ranks with each step of the
LAR algorithm, using simulated data.

·

·

By construction the coeﬃcients in LAR change in a piecewise linear fash-
ion. Figure 3.15 [left panel] shows the LAR coeﬃcient proﬁle evolving as a
function of their L1 arc length 2. Note that we do not need to take small

S

2The L1 arc-length of a diﬀerentiable curve β(s) for s ∈ [0, S] is given by TV(β, S) =
0 || ˙β(s)||1ds, where ˙β(s) = ∂β(s)/∂s. For the piecewise-linear LAR coeﬃcient proﬁle,
R
this amounts to summing the L1 norms of the changes in coeﬃcients from step to step.

3.4 Shrinkage Methods

75

v2

v6

v4

v5

v3

v1

s
n
o
i
t
a
l
e
r
r
o
C

l

e
t
u
o
s
b
A

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

0

5

10

15

L1 Arc Length

FIGURE 3.14. Progression of the absolute correlations during each step of the
LAR procedure, using a simulated data set with six predictors. The labels at the
top of the plot indicate which variables enter the active set at each step. The step
length are measured in units of L1 arc length.

Least Angle Regression

Lasso

s
t
n
e
i
c
ﬃ
e
o
C

5
.
0

0
.
0

5
.
0
−

0
.
1
−

5
.
1
−

s
t
n
e
i
c
ﬃ
e
o
C

5
.
0

0
.
0

5
.
0
−

0
.
1
−

5
.
1
−

0

5

10

15

0

5

10

15

L1 Arc Length

L1 Arc Length

FIGURE 3.15. Left panel shows the LAR coeﬃcient proﬁles on the simulated
data, as a function of the L1 arc length. The right panel shows the Lasso proﬁle.
They are identical until the dark-blue coeﬃcient crosses zero at an arc length of
about 18.

76

3. Linear Methods for Regression

steps and recheck the correlations in step 3; using knowledge of the covari-
ance of the predictors and the piecewise linearity of the algorithm, we can
work out the exact step length at the beginning of each step (Exercise 3.25).
The right panel of Figure 3.15 shows the lasso coeﬃcient proﬁles on the
same data. They are almost identical to those in the left panel, and diﬀer
for the ﬁrst time when the blue coeﬃcient passes back through zero. For the
prostate data, the LAR coeﬃcient proﬁle turns out to be identical to the
lasso proﬁle in Figure 3.10, which never crosses zero. These observations
lead to a simple modiﬁcation of the LAR algorithm that gives the entire
lasso path, which is also piecewise-linear.

Algorithm 3.2a Least Angle Regression: Lasso Modiﬁcation.

4a. If a non-zero coeﬃcient hits zero, drop its variable from the active set
of variables and recompute the current joint least squares direction.

The LAR(lasso) algorithm is extremely eﬃcient, requiring the same order
of computation as that of a single least squares ﬁt using the p predictors.
Least angle regression always takes p steps to get to the full least squares
estimates. The lasso path can have more than p steps, although the two
are often quite similar. Algorithm 3.2 with the lasso modiﬁcation 3.2a is
an eﬃcient way of computing the solution to any lasso problem, especially
when p
N . Osborne et al. (2000a) also discovered a piecewise-linear path
for computing the lasso, which they called a homotopy algorithm.

≫

We now give a heuristic argument for why these procedures are so similar.
Although the LAR algorithm is stated in terms of correlations, if the input
features are standardized, it is equivalent and easier to work with inner-
products. Suppose
is the active set of variables at some stage in the
algorithm, tied in their absolute inner-product with the current residuals
y

Xβ. We can express this as

A

−

xT
j (y

−

Xβ) = γ

sj,

·

j

∀

∈ A

(3.56)

1, 1
where sj ∈ {−
}
xT
k (y
common value. Also
criterion (3.52), which we write in vector form

indicates the sign of the inner-product, and γ is the
. Now consider the lasso

Xβ)

6∈ A

| ≤

−

∀

k

γ

|

R(β) = 1

y

2 ||

Xβ

2
2 + λ

β

||1.

||
be the active set of variables in the solution for a given value of λ.
Let
For these variables R(β) is diﬀerentiable, and the stationarity conditions
give

−

B

||

(3.57)

xT
j (y

Xβ) = λ

sign(βj),

j

·
Comparing (3.58) with (3.56), we see that they are identical only if the
sign of βj matches the sign of the inner product. That is why the LAR

∈ B

−

∀

(3.58)

3.4 Shrinkage Methods

77

algorithm and lasso start to diﬀer when an active coeﬃcient passes through
zero; condition (3.58) is violated for that variable, and it is kicked out of the
active set
. Exercise 3.23 shows that these equations imply a piecewise-
linear coeﬃcient proﬁle as λ decreases. The stationarity conditions for the
non-active variables require that

B

xT
k (y

|

−

Xβ)

λ,

k

∀

,

6∈ B

| ≤

(3.59)

which again agrees with the LAR algorithm.

Figure 3.16 compares LAR and lasso to forward stepwise and stagewise
regression. The setup is the same as in Figure 3.6 on page 59, except here
N = 100 here rather than 300, so the problem is more diﬃcult. We see
that the more aggressive forward stepwise starts to overﬁt quite early (well
before the 10 true variables can enter the model), and ultimately performs
worse than the slower forward stagewise regression. The behavior of LAR
and lasso is similar to that of forward stagewise regression. Incremental
forward stagewise is similar to LAR and lasso, and is described in Sec-
tion 3.8.1.

Degrees-of-Freedom Formula for LAR and Lasso

Suppose that we ﬁt a linear model via the least angle regression procedure,
stopping at some number of steps k < p, or equivalently using a lasso bound
t that produces a constrained version of the full least squares ﬁt. How many
parameters, or “degrees of freedom” have we used?

Consider ﬁrst a linear regression using a subset of k features. If this subset
is prespeciﬁed in advance without reference to the training data, then the
degrees of freedom used in the ﬁtted model is deﬁned to be k. Indeed, in
classical statistics, the number of linearly independent parameters is what
is meant by “degrees of freedom.” Alternatively, suppose that we carry out
a best subset selection to determine the “optimal” set of k predictors. Then
the resulting model has k parameters, but in some sense we have used up
more than k degrees of freedom.

We need a more general deﬁnition for the eﬀective degrees of freedom of
an adaptively ﬁtted model. We deﬁne the degrees of freedom of the ﬁtted
vector ˆy = (ˆy1, ˆy2, . . . , ˆyN ) as

df(ˆy) =

1
σ2

N

i=1
X

Cov(ˆyi, yi).

(3.60)

Here Cov(ˆyi, yi) refers to the sampling covariance between the predicted
value ˆyi and its corresponding outcome value yi. This makes intuitive sense:
the harder that we ﬁt to the data, the larger this covariance and hence
df(ˆy). Expression (3.60) is a useful notion of degrees of freedom, one that
can be applied to any model prediction ˆy. This includes models that are

78

3. Linear Methods for Regression

2

|
|

β

−

)
k
(
ˆβ

|
|

E

5
6
.
0

0
6
.
0

5
5
.
0

Forward Stepwise
LAR
Lasso
Forward Stagewise
Incremental Forward Stagewise

0.0

0.2

0.4

0.6

0.8

1.0

Fraction of L1 arc-length

FIGURE 3.16. Comparison of LAR and lasso with forward stepwise, forward
stagewise (FS) and incremental forward stagewise (FS0) regression. The setup
is the same as in Figure 3.6, except N = 100 here rather than 300. Here the
slower FS regression ultimately outperforms forward stepwise. LAR and lasso
show similar behavior to FS and FS0. Since the procedures take diﬀerent numbers
of steps (across simulation replicates and methods), we plot the MSE as a function
of the fraction of total L1 arc-length toward the least-squares ﬁt.

adaptively ﬁtted to the training data. This deﬁnition is motivated and
discussed further in Sections 7.4–7.6.

Now for a linear regression with k ﬁxed predictors, it is easy to show
that df(ˆy) = k. Likewise for ridge regression, this deﬁnition leads to the
closed-form expression (3.50) on page 68: df(ˆy) = tr(Sλ). In both these
cases, (3.60) is simple to evaluate because the ﬁt ˆy = Hλy is linear in y.
If we think about deﬁnition (3.60) in the context of a best subset selection
of size k, it seems clear that df(ˆy) will be larger than k, and this can be
veriﬁed by estimating Cov(ˆyi, yi)/σ2 directly by simulation. However there
is no closed form method for estimating df(ˆy) for best subset selection.

For LAR and lasso, something magical happens. These techniques are
adaptive in a smoother way than best subset selection, and hence estimation
of degrees of freedom is more tractable. Speciﬁcally it can be shown that
after the kth step of the LAR procedure, the eﬀective degrees of freedom of
the ﬁt vector is exactly k. Now for the lasso, the (modiﬁed) LAR procedure

3.5 Methods Using Derived Input Directions

79

often takes more than p steps, since predictors can drop out. Hence the
deﬁnition is a little diﬀerent; for the lasso, at any stage df(ˆy) approximately
equals the number of predictors in the model. While this approximation
works reasonably well anywhere in the lasso path, for each k it works best
at the last model in the sequence that contains k predictors. A detailed
study of the degrees of freedom for the lasso may be found in Zou et al.
(2007).

3.5 Methods Using Derived Input Directions

In many situations we have a large number of inputs, often very correlated.
The methods in this section produce a small number of linear combinations
Zm, m = 1, . . . , M of the original inputs Xj, and the Zm are then used in
place of the Xj as inputs in the regression. The methods diﬀer in how the
linear combinations are constructed.

3.5.1 Principal Components Regression

In this approach the linear combinations Zm used are the principal com-
ponents as deﬁned in Section 3.4.1 above.

Principal component regression forms the derived input columns zm =
p. Since the zm

Xvm, and then regresses y on z1, z2, . . . , zM for some M
are orthogonal, this regression is just a sum of univariate regressions:

≤

ˆypcr
(M ) = ¯y1 +

ˆθmzm,

M

m=1
X

(3.61)

zm, y

where ˆθm =
. Since the zm are each linear combinations
of the original xj, we can express the solution (3.61) in terms of coeﬃcients
of the xj (Exercise 3.13):

zm, zmi

/
h

h

i

M

ˆβpcr(M ) =

ˆθmvm.

m=1
X

(3.62)

As with ridge regression, principal components depend on the scaling of
the inputs, so typically we ﬁrst standardize them. Note that if M = p, we
would just get back the usual least squares estimates, since the columns of
Z = UD span the column space of X. For M < p we get a reduced regres-
sion. We see that principal components regression is very similar to ridge
regression: both operate via the principal components of the input ma-
trix. Ridge regression shrinks the coeﬃcients of the principal components
(Figure 3.17), shrinking more depending on the size of the corresponding
M smallest
eigenvalue; principal components regression discards the p
eigenvalue components. Figure 3.17 illustrates this.

−

80

3. Linear Methods for Regression

•
•

r
o
t
c
a
F
e
g
a
k
n
i
r
h
S

0

.

1

8

.

0

6

.

0

4

.

0

2
0

.

0
0

.

•

•

ridge
pcr

•

•

2

•

•

•

•

4

Index

•

•

•

•

•

6

•

•

8

FIGURE 3.17. Ridge regression shrinks the regression coeﬃcients of the prin-
cipal components, using shrinkage factors d2
j + λ) as in (3.47). Principal
component regression truncates them. Shown are the shrinkage and truncation
patterns corresponding to Figure 3.7, as a function of the principal component
index.

j /(d2

In Figure 3.7 we see that cross-validation suggests seven terms; the re-

sulting model has the lowest test error in Table 3.3.

3.5.2 Partial Least Squares

h

i

xj, y

This technique also constructs a set of linear combinations of the inputs
for regression, but unlike principal components regression it uses y (in ad-
dition to X) for this construction. Like principal component regression,
partial least squares (PLS) is not scale invariant, so we assume that each
xj is standardized to have mean 0 and variance 1. PLS begins by com-
for each j. From this we construct the derived input
puting ˆϕ1j =
j ˆϕ1jxj, which is the ﬁrst partial least squares direction. Hence
z1 =
in the construction of each zm, the inputs are weighted by the strength
of their univariate eﬀect on y3. The outcome y is regressed on z1 giving
coeﬃcient ˆθ1, and then we orthogonalize x1, . . . , xp with respect to z1. We
p directions have been obtained. In this
continue this process, until M
manner, partial least squares produces a sequence of derived, orthogonal
inputs or directions z1, z2, . . . , zM . As with principal-component regres-
sion, if we were to construct all M = p directions, we would get back a
solution equivalent to the usual least squares estimates; using M < p di-
rections produces a reduced regression. The procedure is described fully in
Algorithm 3.3.

P

≤

3Since the xj are standardized, the ﬁrst directions ˆϕ1j are the univariate regression
coeﬃcients (up to an irrelevant constant); this is not the case for subsequent directions.

 
3.5 Methods Using Derived Input Directions

81

Algorithm 3.3 Partial Least Squares.

1. Standardize each xj to have mean zero and variance one. Set ˆy(0) =

¯y1, and x(0)

j = xj, j = 1, . . . , p.

2. For m = 1, 2, . . . , p

, where ˆϕmj =

x(m−1)
j

, y

.

i

h

j

p

j=1 ˆϕmjx(m−1)
(a) zm =
(b) ˆθm =
zm, zmi
zm, y
.
P
h
(c) ˆy(m) = ˆy(m−1) + ˆθmzm.
(d) Orthogonalize each x(m−1)

/
h

i

j

with respect to zm: x(m)

j = x(m−1)

j

−

[

zm, x(m−1)
j

/
h

zm, zmi

]zm, j = 1, 2, . . . , p.

h

i
3. Output the sequence of ﬁtted vectors

m
1 are
linear in the original xj, so is ˆy(m) = X ˆβpls(m). These linear coeﬃ-
cients can be recovered from the sequence of PLS transformations.

p
1. Since the
}

ˆy(m)
{

zℓ}
{

In the prostate cancer example, cross-validation chose M = 2 PLS direc-
tions in Figure 3.7. This produced the model given in the rightmost column
of Table 3.3.

What optimization problem is partial least squares solving? Since it uses
the response y to construct its directions, its solution path is a nonlinear
function of y. It can be shown (Exercise 3.15) that partial least squares
seeks directions that have high variance and have high correlation with the
response, in contrast to principal components regression which keys only
on high variance (Stone and Brooks, 1990; Frank and Friedman, 1993). In
particular, the mth principal component direction vm solves:

maxα Var(Xα)

(3.63)

subject to

α

||

||

= 1, αT Svℓ = 0, ℓ = 1, . . . , m

1,

−

where S is the sample covariance matrix of the xj. The conditions αT Svℓ =
0 ensures that zm = Xα is uncorrelated with all the previous linear com-
binations zℓ = Xvℓ. The mth PLS direction ˆϕm solves:

subject to

maxα Corr2(y, Xα)Var(Xα)
α

= 1, αT S ˆϕℓ = 0, ℓ = 1, . . . , m

||

||

(3.64)

1.

−

Further analysis reveals that the variance aspect tends to dominate, and
so partial least squares behaves much like ridge regression and principal
components regression. We discuss this further in the next section.

If the input matrix X is orthogonal, then partial least squares ﬁnds the
least squares estimates after m = 1 steps. Subsequent steps have no eﬀect

82

3. Linear Methods for Regression

since the ˆϕmj are zero for m > 1 (Exercise 3.14). It can also be shown that
the sequence of PLS coeﬃcients for m = 1, 2, . . . , p represents the conjugate
gradient sequence for computing the least squares solutions (Exercise 3.18).

3.6 Discussion: A Comparison of the Selection and

Shrinkage Methods

There are some simple settings where we can understand better the rela-
tionship between the diﬀerent methods described above. Consider an exam-
ple with two correlated inputs X1 and X2, with correlation ρ. We assume
that the true regression coeﬃcients are β1 = 4 and β2 = 2. Figure 3.18
shows the coeﬃcient proﬁles for the diﬀerent methods, as their tuning pa-
rameters are varied. The top panel has ρ = 0.5, the bottom panel ρ =
0.5.
The tuning parameters for ridge and lasso vary over a continuous range,
while best subset, PLS and PCR take just two discrete steps to the least
squares solution. In the top panel, starting at the origin, ridge regression
shrinks the coeﬃcients together until it ﬁnally converges to least squares.
PLS and PCR show similar behavior to ridge, although are discrete and
more extreme. Best subset overshoots the solution and then backtracks.
The behavior of the lasso is intermediate to the other methods. When the
correlation is negative (lower panel), again PLS and PCR roughly track
the ridge path, while all of the methods are more similar to one another.

−

It is interesting to compare the shrinkage behavior of these diﬀerent
methods. Recall that ridge regression shrinks all directions, but shrinks
low-variance directions more. Principal components regression leaves M
high-variance directions alone, and discards the rest. Interestingly, it can
be shown that partial least squares also tends to shrink the low-variance
directions, but can actually inﬂate some of the higher variance directions.
This can make PLS a little unstable, and cause it to have slightly higher
prediction error compared to ridge regression. A full study is given in Frank
and Friedman (1993). These authors conclude that for minimizing predic-
tion error, ridge regression is generally preferable to variable subset selec-
tion, principal components regression and partial least squares. However
the improvement over the latter two methods was only slight.

To summarize, PLS, PCR and ridge regression tend to behave similarly.
Ridge regression may be preferred because it shrinks smoothly, rather than
in discrete steps. Lasso falls somewhere between ridge regression and best
subset regression, and enjoys some of the properties of each.

3.6 Discussion: A Comparison of the Selection and Shrinkage Methods

83

3

2

1

2
β

0

0

ρ = 0.5

PCR

PLS
Ridge

•

Least Squares

Lasso

Best Subset

1
-

3

2

1

2
β

0

0

0

1

2

3

β1

4

5

6

ρ =

0.5

−

•

Least Squares

Ridge

Lasso

Best Subset

1
-

PCR

0

1

2

PLS

3

β1

4

5

6

FIGURE 3.18. Coeﬃcient proﬁles from diﬀerent methods for a simple problem:
0.5, and the true regression coeﬃcients β = (4, 2).
two inputs with correlation

±

84

3. Linear Methods for Regression

3.7 Multiple Outcome Shrinkage and Selection

As noted in Section 3.2.4, the least squares estimates in a multiple-output
linear model are simply the individual least squares estimates for each of
the outputs.

To apply selection and shrinkage methods in the multiple output case,
one could apply a univariate technique individually to each outcome or si-
multaneously to all outcomes. With ridge regression, for example, we could
apply formula (3.44) to each of the K columns of the outcome matrix Y ,
using possibly diﬀerent parameters λ, or apply it to all columns using the
same value of λ. The former strategy would allow diﬀerent amounts of
regularization to be applied to diﬀerent outcomes but require estimation
of k separate regularization parameters λ1, . . . , λk, while the latter would
permit all k outputs to be used in estimating the sole regularization pa-
rameter λ.

Other more sophisticated shrinkage and selection strategies that exploit
correlations in the diﬀerent responses can be helpful in the multiple output
case. Suppose for example that among the outputs we have

Yk = f (X) + εk
Yℓ = f (X) + εℓ;

(3.65)

(3.66)

i.e., (3.65) and (3.66) share the same structural part f (X) in their models.
It is clear in this case that we should pool our observations on Yk and Yl
to estimate the common f .

Combining responses is at the heart of canonical correlation analysis
(CCA), a data reduction technique developed for the multiple output case.
Similar to PCA, CCA ﬁnds a sequence of uncorrelated linear combina-
tions Xvm, m = 1, . . . , M of the xj, and a corresponding sequence of
uncorrelated linear combinations Yum of the responses yk, such that the
correlations

Corr2(Yum, Xvm)

(3.67)

are successively maximized. Note that at most M = min(K, p) directions
can be found. The leading canonical response variates are those linear com-
binations (derived responses) best predicted by the xj; in contrast, the
trailing canonical variates can be poorly predicted by the xj, and are can-
didates for being dropped. The CCA solution is computed using a general-
ized SVD of the sample cross-covariance matrix YT X/N (assuming Y and
X are centered; Exercise 3.20).

Reduced-rank regression (Izenman, 1975; van der Merwe and Zidek, 1980)
formalizes this approach in terms of a regression model that explicitly pools
information. Given an error covariance Cov(ε) = Σ, we solve the following

3.7 Multiple Outcome Shrinkage and Selection

85

restricted multivariate regression problem:

ˆBrr(m) = argmin
rank(B)=m

N

i=1
X

(yi −

BT xi)T Σ−1(yi −

BT xi).

(3.68)

With Σ replaced by the estimate YT Y/N , one can show (Exercise 3.21)
that the solution is given by a CCA of Y and X:

ˆBrr(m) = ˆBUmU−
m,

(3.69)

where Um is the K
and U is the K
is its generalized inverse. Writing the solution as

m sub-matrix of U consisting of the ﬁrst m columns,
×
M matrix of left canonical vectors u1, u2, . . . , uM . U−
m

×

ˆBrr(M ) = (XT X)−1XT (YUm)U−
m,

(3.70)

we see that reduced-rank regression performs a linear regression on the
pooled response matrix YUm, and then maps the coeﬃcients (and hence
the ﬁts as well) back to the original response space. The reduced-rank ﬁts
are given by

ˆYrr(m) = X(XT X)−1XT YUmU−
m

= HYPm,

(3.71)

where H is the usual linear regression projection operator, and Pm is the
rank-m CCA response projection operator. Although a better estimate of
Σ would be (Y
pK), one can show that the solution
−
remains the same (Exercise 3.22).

X ˆB)T (Y

X ˆB)/(N

−

−

Reduced-rank regression borrows strength among responses by truncat-
ing the CCA. Breiman and Friedman (1997) explored with some success
shrinkage of the canonical variates between X and Y, a smooth version of
reduced rank regression. Their proposal has the form (compare (3.69))

ˆBc+w = ˆBUΛU−1,

(3.72)

where Λ is a diagonal shrinkage matrix (the “c+w” stands for “Curds
and Whey,” the name they gave to their procedure). Based on optimal
prediction in the population setting, they show that Λ has diagonal entries

λm =

c2
m
m + p
c2
N (1

c2
m)

−

, m = 1, . . . , M,

(3.73)

where cm is the mth canonical correlation coeﬃcient. Note that as the ratio
of the number of input variables to sample size p/N gets small, the shrink-
age factors approach 1. Breiman and Friedman (1997) proposed modiﬁed
versions of Λ based on training data and cross-validation, but the general
form is the same. Here the ﬁtted response has the form

ˆYc+w = HYSc+w,

(3.74)

86

3. Linear Methods for Regression

where Sc+w = UΛU−1 is the response shrinkage operator.

Breiman and Friedman (1997) also suggested shrinking in both the Y

space and X space. This leads to hybrid shrinkage models of the form

ˆYridge,c+w = AλYSc+w,

(3.75)

where Aλ = X(XT X + λI)−1XT is the ridge regression shrinkage operator,
as in (3.46) on page 66. Their paper and the discussions thereof contain
many more details.

3.8 More on the Lasso and Related Path

Algorithms

Since the publication of the LAR algorithm (Efron et al., 2004) there has
been a lot of activity in developing algorithms for ﬁtting regularization
paths for a variety of diﬀerent problems. In addition, L1 regularization has
taken on a life of its own, leading to the development of the ﬁeld compressed
sensing in the signal-processing literature. (Donoho, 2006a; Candes, 2006).
In this section we discuss some related proposals and other path algorithms,
starting oﬀ with a precursor to the LAR algorithm.

3.8.1 Incremental Forward Stagewise Regression

Here we present another LAR-like algorithm, this time focused on forward
stagewise regression. Interestingly, eﬀorts to understand a ﬂexible nonlinear
regression procedure (boosting) led to a new algorithm for linear models
(LAR). In reading the ﬁrst edition of this book and the forward stagewise

Algorithm 3.4 Incremental Forward Stagewise Regression—FSǫ.

1. Start with the residual r equal to y and β1, β2, . . . , βp = 0. All the

predictors are standardized to have mean zero and unit norm.

2. Find the predictor xj most correlated with r

3. Update βj ←

step size, and set r

βj + δj, where δj = ǫ

r

−

←

δjxj.

sign[

xj, r

i

h

·

] and ǫ > 0 is a small

4. Repeat steps 2 and 3 many times, until the residuals are uncorrelated

with all the predictors.

Algorithm 16.1 of Chapter 164, our colleague Brad Efron realized that with

4In the ﬁrst edition, this was Algorithm 10.4 in Chapter 10.

3.8 More on the Lasso and Related Path Algorithms

87

FSǫ

FS0

lcavol

lcavol

s
t
n
e
i
c
ﬃ
e
o
C

6
.
0

4
.
0

2
.
0

0
.
0

2
.
0
−

s
t
n
e
i
c
ﬃ
e
o
C

6
.
0

4
.
0

2
.
0

0
.
0

2
.
0
−

svi
lweight
pgg45
lbph

gleason

age

lcp

svi
lweight
pgg45
lbph

gleason

age

lcp

0

50

100

150

200

0.0

0.5

1.0

1.5

2.0

Iteration

L1 Arc-length of Coeﬃcients

FIGURE 3.19. Coeﬃcient proﬁles for the prostate data. The left panel shows
incremental forward stagewise regression with step size ǫ = 0.01. The right panel
shows the inﬁnitesimal version FS0 obtained letting ǫ
0. This proﬁle was ﬁt by
the modiﬁcation 3.2b to the LAR Algorithm 3.2. In this example the FS0 proﬁles
are monotone, and hence identical to those of lasso and LAR.

→

linear models, one could explicitly construct the piecewise-linear lasso paths
of Figure 3.10. This led him to propose the LAR procedure of Section 3.4.4,
as well as the incremental version of forward-stagewise regression presented
here.

Consider the linear-regression version of the forward-stagewise boosting
algorithm 16.1 proposed in Section 16.1 (page 608). It generates a coeﬃcient
proﬁle by repeatedly updating (by a small amount ǫ) the coeﬃcient of the
variable most correlated with the current residuals. Algorithm 3.4 gives
the details. Figure 3.19 (left panel) shows the progress of the algorithm on
(the least-squares
the prostate data with step size ǫ = 0.01. If δj =
coeﬃcient of the residual on jth predictor), then this is exactly the usual
forward stagewise procedure (FS) outlined in Section 3.3.3.

xj, r

i

h

Here we are mainly interested in small values of ǫ. Letting ǫ

0 gives
the right panel of Figure 3.19, which in this case is identical to the lasso
path in Figure 3.10. We call this limiting procedure inﬁnitesimal forward
stagewise regression or FS0. This procedure plays an important role in
non-linear, adaptive methods like boosting (Chapters 10 and 16) and is the
version of incremental forward stagewise regression that is most amenable
to theoretical analysis. B¨uhlmann and Hothorn (2007) refer to the same
procedure as “L2boost”, because of its connections to boosting.

→

88

3. Linear Methods for Regression

Efron originally thought that the LAR Algorithm 3.2 was an implemen-
tation of FS0, allowing each tied predictor a chance to update their coeﬃ-
cients in a balanced way, while remaining tied in correlation. However, he
then realized that the LAR least-squares ﬁt amongst the tied predictors
can result in coeﬃcients moving in the opposite direction to their correla-
tion, which cannot happen in Algorithm 3.4. The following modiﬁcation of
the LAR algorithm implements FS0:

Algorithm 3.2b Least Angle Regression: FS0 Modiﬁcation.

4. Find the new direction by solving the constrained least squares prob-

lem

min
b

r

−
where sj is the sign of

||

XAb

2

2 subject to bjsj ≥
.

||
xj, r

h

i

0, j

,

∈ A

The modiﬁcation amounts to a non-negative least squares ﬁt, keeping the
signs of the coeﬃcients the same as those of the correlations. One can show
that this achieves the optimal balancing of inﬁnitesimal “update turns”
for the variables tied for maximal correlation (Hastie et al., 2007). Like
lasso, the entire FS0 path can be computed very eﬃciently via the LAR
algorithm.

As a consequence of these results, if the LAR proﬁles are monotone non-
increasing or non-decreasing, as they are in Figure 3.19, then all three
methods—LAR, lasso, and FS0—give identical proﬁles. If the proﬁles are
not monotone but do not cross the zero axis, then LAR and lasso are
identical.

Since FS0 is diﬀerent from the lasso, it is natural to ask if it optimizes
a criterion. The answer is more complex than for lasso; the FS0 coeﬃcient
proﬁle is the solution to a diﬀerential equation. While the lasso makes op-
timal progress in terms of reducing the residual sum-of-squares per unit
increase in L1-norm of the coeﬃcient vector β, FS0 is optimal per unit
increase in L1 arc-length traveled along the coeﬃcient path. Hence its co-
eﬃcient path is discouraged from changing directions too often.

FS0 is more constrained than lasso, and in fact can be viewed as a mono-
tone version of the lasso; see Figure 16.3 on page 614 for a dramatic exam-
ple. FS0 may be useful in p
N situations, where its coeﬃcient proﬁles
are much smoother and hence have less variance than those of lasso. More
details on FS0 are given in Section 16.2.3 and Hastie et al. (2007). Fig-
ure 3.16 includes FS0 where its performance is very similar to that of the
lasso.

≫

3.8 More on the Lasso and Related Path Algorithms

89

3.8.2 Piecewise-Linear Path Algorithms

The least angle regression procedure exploits the piecewise linear nature of
the lasso solution paths. It has led to similar “path algorithms” for other
regularized problems. Suppose we solve

ˆβ(λ) = argminβ [R(β) + λJ(β)] ,

(3.76)

with

N

p

R(β) =

L(yi, β0 +

xijβj),

(3.77)

i=1
X

j=1
X

where both the loss function L and the penalty function J are convex.
Then the following are suﬃcient conditions for the solution path ˆβ(λ) to
be piecewise linear (Rosset and Zhu, 2007):

1. R is quadratic or piecewise-quadratic as a function of β, and

2. J is piecewise linear in β.

This also implies (in principle) that the solution path can be eﬃciently
computed. Examples include squared- and absolute-error loss, “Huberized”
losses, and the L1, L∞ penalties on β. Another example is the “hinge loss”
function used in the support vector machine. There the loss is piecewise
linear, and the penalty is quadratic. Interestingly, this leads to a piecewise-
linear path algorithm in the dual space; more details are given in Sec-
tion 12.3.5.

3.8.3 The Dantzig Selector

Candes and Tao (2007) proposed the following criterion:

minβ||

β

||1 subject to

||

XT (y

Xβ)

s.

||∞ ≤

−

(3.78)

They call the solution the Dantzig selector (DS). It can be written equiva-
lently as

XT (y

Xβ)

||

β

t.

−

||1 ≤

minβ||

||∞ subject to
Here
|| · ||∞ denotes the L∞ norm, the maximum absolute value of the
components of the vector. In this form it resembles the lasso, replacing
squared error loss by the maximum absolute value of its gradient. Note
that as t gets large, both procedures yield the least squares solution if
N < p. If p
N , they both yield the least squares solution with minimum
L1 norm. However for smaller values of t, the DS procedure produces a
diﬀerent path of solutions than the lasso.

(3.79)

≥

Candes and Tao (2007) show that the solution to DS is a linear pro-
gramming problem; hence the name Dantzig selector, in honor of the late

90

3. Linear Methods for Regression

George Dantzig, the inventor of the simplex method for linear program-
ming. They also prove a number of interesting mathematical properties for
the method, related to its ability to recover an underlying sparse coeﬃ-
cient vector. These same properties also hold for the lasso, as shown later
by Bickel et al. (2008).

Unfortunately the operating properties of the DS method are somewhat
unsatisfactory. The method seems similar in spirit to the lasso, especially
when we look at the lasso’s stationary conditions (3.58). Like the LAR al-
gorithm, the lasso maintains the same inner product (and correlation) with
the current residual for all variables in the active set, and moves their co-
eﬃcients to optimally decrease the residual sum of squares. In the process,
this common correlation is decreased monotonically (Exercise 3.23), and at
all times this correlation is larger than that for non-active variables. The
Dantzig selector instead tries to minimize the maximum inner product of
the current residual with all the predictors. Hence it can achieve a smaller
maximum than the lasso, but in the process a curious phenomenon can
occur. If the size of the active set is m, there will be m variables tied with
maximum correlation. However, these need not coincide with the active set!
Hence it can include a variable in the model that has smaller correlation
with the current residual than some of the excluded variables (Efron et
al., 2007). This seems unreasonable and may be responsible for its some-
times inferior prediction accuracy. Efron et al. (2007) also show that DS
can yield extremely erratic coeﬃcient paths as the regularization parameter
s is varied.

3.8.4 The Grouped Lasso

In some problems, the predictors belong to pre-deﬁned groups; for example
genes that belong to the same biological pathway, or collections of indicator
(dummy) variables for representing the levels of a categorical predictor. In
this situation it may be desirable to shrink and select the members of a
group together. The grouped lasso is one way to achieve this. Suppose that
the p predictors are divided into L groups, with pℓ the number in group
ℓ. For ease of notation, we use a matrix Xℓ to represent the predictors
corresponding to the ℓth group, with corresponding coeﬃcient vector βℓ.
The grouped-lasso minimizes the convex criterion

min
β∈IRp  ||

y

−

β01

−

L

Xℓ=1

Xℓβℓ||

2
2 + λ

L

Xℓ=1

√pℓ||

βℓ||2

,

!

(3.80)

where the √pℓ terms accounts for the varying group sizes, and
|| · ||2 is
the Euclidean norm (not squared). Since the Euclidean norm of a vector
βℓ is zero only if all of its components are zero, this procedure encourages
sparsity at both the group and individual levels. That is, for some values of
λ, an entire group of predictors may drop out of the model. This procedure

3.8 More on the Lasso and Related Path Algorithms

91

was proposed by Bakin (1999) and Lin and Zhang (2006), and studied and
generalized by Yuan and Lin (2007). Generalizations include more general
||K = (ηT Kη)1/2, as well as allowing overlapping groups of
L2 norms
predictors (Zhao et al., 2008). There are also connections to methods for
ﬁtting sparse additive models (Lin and Zhang, 2006; Ravikumar et al.,
2008).

||

η

3.8.5 Further Properties of the Lasso

A number of authors have studied the ability of the lasso and related pro-
cedures to recover the correct model, as N and p grow. Examples of this
work include Knight and Fu (2000), Greenshtein and Ritov (2004), Tropp
(2004), Donoho (2006b), Meinshausen (2007), Meinshausen and B¨uhlmann
(2006), Tropp (2006), Zhao and Yu (2006), Wainwright (2006), and Bunea
et al. (2007). For example Donoho (2006b) focuses on the p > N case and
considers the lasso solution as the bound t gets large. In the limit this gives
the solution with minimum L1 norm among all models with zero training
error. He shows that under certain assumptions on the model matrix X, if
the true model is sparse, this solution identiﬁes the correct predictors with
high probability.

Many of the results in this area assume a condition on the model matrix

of the form

max
j∈S c ||

xT
j XS (XS

T XS )−1

||1 ≤

(1

−

ǫ) for some ǫ

∈

(0, 1].

(3.81)

S

S

Here
indexes the subset of features with non-zero coeﬃcients in the true
underlying model, and XS are the columns of X corresponding to those
c are the features with true coeﬃcients equal to zero,
features. Similarly
and XS c the corresponding columns. This says that the least squares coef-
ﬁcients for the columns of XS c on XS are not too large, that is, the “good”
variables

are not too highly correlated with the nuisance variables

c.

S

Regarding the coeﬃcients themselves, the lasso shrinkage causes the esti-
mates of the non-zero coeﬃcients to be biased towards zero, and in general
they are not consistent5. One approach for reducing this bias is to run
the lasso to identify the set of non-zero coeﬃcients, and then ﬁt an un-
restricted linear model to the selected set of features. This is not always
feasible, if the selected set is large. Alternatively, one can use the lasso to
select the set of non-zero predictors, and then apply the lasso again, but
using only the selected predictors from the ﬁrst step. This is known as the
relaxed lasso (Meinshausen, 2007). The idea is to use cross-validation to
estimate the initial penalty parameter for the lasso, and then again for a
second penalty parameter applied to the selected set of predictors. Since

S

5Statistical consistency means as the sample size grows, the estimates converge to

the true values.

92

3. Linear Methods for Regression

the variables in the second step have less “competition” from noise vari-
ables, cross-validation will tend to pick a smaller value for λ, and hence
their coeﬃcients will be shrunken less than those in the initial estimate.

Alternatively, one can modify the lasso penalty function so that larger co-
eﬃcients are shrunken less severely; the smoothly clipped absolute deviation
(SCAD) penalty of Fan and Li (2005) replaces λ

by Ja(β, λ), where

β

dJa(β, λ)
dβ

= λ

·

sign(β)

I(

β

|

| ≤

λ) +

(aλ
(a

h

|
)+

|
β
|
1)λ

− |
−

I(

β

|

|

> λ)

i

(3.82)

2. The second term in square-braces reduces the amount of
for some a
shrinkage in the lasso for larger values of β, with ultimately no shrinkage
. Figure 3.20 shows the SCAD penalty, along with the lasso and
as a

≥

→ ∞

|β|

SCAD

|β|1−ν

5

4

3

2

1

0

5
2

.

0
2

.

5
1

.

0
1

.

5
0

.

0
0

.

0
2

.

5
1

.

0
1

.

5

.

0

−4

−2

0

β

2

4

−4

−2

0

β

2

4

−4

−2

2

4

0

β

FIGURE 3.20. The lasso and two alternative non-convex penalties designed to
penalize large coeﬃcients less. For SCAD we use λ = 1 and a = 4, and ν = 1
2 in
the last panel.

|

1−ν. However this criterion is non-convex, which is a drawback since it
β
|
makes the computation much more diﬃcult. The adaptive lasso (Zou, 2006)
ν, ˆβj is
uses a weighted penalty of the form
the ordinary least squares estimate and ν > 0. This is a practical approxi-
P
mation to the
ν here) discussed in Section 3.4.3. The
adaptive lasso yields consistent estimates of the parameters while retaining
the attractive convexity property of the lasso.

where wj = 1/
|

q penalties (q = 1

j=1 wj|

ˆβj|

βj|

−

β

p

|

|

3.8.6 Pathwise Coordinate Optimization

An alternate approach to the LARS algorithm for computing the lasso
solution is simple coordinate descent. This idea was proposed by Fu (1998)
and Daubechies et al. (2004), and later studied and generalized by Friedman
et al. (2007), Wu and Lange (2008) and others. The idea is to ﬁx the penalty
parameter λ in the Lagrangian form (3.52) and optimize successively over
each parameter, holding the other parameters ﬁxed at their current values.
Suppose the predictors are all standardized to have mean zero and unit
norm. Denote by ˜βk(λ) the current estimate for βk at penalty parameter

λ. We can rearrange (3.52) to isolate βj,

3.9 Computational Considerations

93

N

2

1
2

xik ˜βk(λ)

R( ˜β(λ), βj) =

−

Xk6=j

xijβj

yi −

i=1 
X

βj|
(3.83)
where we have suppressed the intercept and introduced a factor 1
2 for con-
venience. This can be viewed as a univariate lasso problem with response
˜y(j)
k6=j xik ˜βk(λ). This has an
variable the partial residual yi −
i = yi −
explicit solution, resulting in the update

Xk6=j

+ λ

+ λ

!

|

,

|

|

˜βk(λ)

P

˜βj(λ)

S

←

N

i=1
X

xij(yi −

˜y(j)
i

), λ

.

!

(3.84)

|

t

|−

λ)+ is the soft-thresholding operator in Table 3.4
Here S(t, λ) = sign(t)(
on page 71. The ﬁrst argument to S(
) is the simple least-squares coeﬃcient
·
of the partial residual on the standardized variable xij. Repeated iteration
of (3.84)—cycling through each variable in turn until convergence—yields
the lasso estimate ˆβ(λ).

We can also use this simple algorithm to eﬃciently compute the lasso
solutions at a grid of values of λ. We start with the smallest value λmax
for which ˆβ(λmax) = 0, decrease it a little and cycle through the variables
until convergence. Then λ is decreased again and the process is repeated,
using the previous solution as a “warm start” for the new value of λ. This
can be faster than the LARS algorithm, especially in large problems. A
key to its speed is the fact that the quantities in (3.84) can be updated
quickly as j varies, and often the update is to leave ˜βj = 0. On the other
hand, it delivers solutions over a grid of λ values, rather than the entire
solution path. The same kind of algorithm can be applied to the elastic
net, the grouped lasso and many other models in which the penalty is a
sum of functions of the individual parameters (Friedman et al., 2010). It
can also be applied, with some substantial modiﬁcations, to the fused lasso
(Section 18.4.2); details are in Friedman et al. (2007).

3.9 Computational Considerations

Least squares ﬁtting is usually done via the Cholesky decomposition of
the matrix XT X or a QR decomposition of X. With N observations and p
features, the Cholesky decomposition requires p3 +N p2/2 operations, while
the QR decomposition requires N p2 operations. Depending on the relative
size of N and p, the Cholesky can sometimes be faster; on the other hand,
it can be less numerically stable (Lawson and Hansen, 1974). Computation
of the lasso via the LAR algorithm has the same order of computation as
a least squares ﬁt.

 
94

3. Linear Methods for Regression

Bibliographic Notes

Linear regression is discussed in many statistics books, for example, Seber
(1984), Weisberg (1980) and Mardia et al. (1979). Ridge regression was
introduced by Hoerl and Kennard (1970), while the lasso was proposed by
Tibshirani (1996). Around the same time, lasso-type penalties were pro-
posed in the basis pursuit method for signal processing (Chen et al., 1998).
The least angle regression procedure was proposed in Efron et al. (2004);
related to this is the earlier homotopy procedure of Osborne et al. (2000a)
and Osborne et al. (2000b). Their algorithm also exploits the piecewise
linearity used in the LAR/lasso algorithm, but lacks its transparency. The
criterion for the forward stagewise criterion is discussed in Hastie et al.
(2007). Park and Hastie (2007) develop a path algorithm similar to least
angle regression for generalized regression models. Partial least squares
was introduced by Wold (1975). Comparisons of shrinkage methods may
be found in Copas (1983) and Frank and Friedman (1993).

Exercises

Ex. 3.1 Show that the F statistic (3.13) for dropping a single coeﬃcient
from a model is equal to the square of the corresponding z-score (3.12).

Ex. 3.2 Given data on two variables X and Y , consider ﬁtting a cubic
3
j=0 βjX j. In addition to plotting
polynomial regression model f (X) =
the ﬁtted curve, you would like a 95% conﬁdence band about the curve.
Consider the following two approaches:

P

1. At each point x0, form a 95% conﬁdence interval for the linear func-

tion aT β =

3

j=0 βjxj
0.

2. Form a 95% conﬁdence set for β as in (3.15), which in turn generates

P

conﬁdence intervals for f (x0).

How do these approaches diﬀer? Which band is likely to be wider? Conduct
a small simulation experiment to compare the two methods.

Ex. 3.3 Gauss–Markov theorem:

(a) Prove the Gauss–Markov theorem: the least squares estimate of a
parameter aT β has variance no bigger than that of any other linear
unbiased estimate of aT β (Section 3.2.2).

(b) The matrix inequality B

B is positive semideﬁnite.
A holds if A
Show that if ˆV is the variance-covariance matrix of the least squares
estimate of β and ˜V is the variance-covariance matrix of any other
linear unbiased estimate, then ˆV

˜V.

−

(cid:22)

(cid:22)

Exercises

95

Ex. 3.4 Show how the vector of least squares coeﬃcients can be obtained
from a single pass of the Gram–Schmidt procedure (Algorithm 3.1). Rep-
resent your solution in terms of the QR decomposition of X.

Ex. 3.5 Consider the ridge regression problem (3.41). Show that this prob-
lem is equivalent to the problem

ˆβc = argmin

βc (

N

i=1
X

yi −

βc
0 −

p

j=1
X

(cid:2)

(xij −

¯xj)βc
j

2

+ λ

(cid:3)

p

j=1
X

2

βc
j

.
)

(3.85)

Give the correspondence between βc and the original β in (3.41). Char-
acterize the solution to this modiﬁed criterion. Show that a similar result
holds for the lasso.

Ex. 3.6 Show that the ridge regression estimate is the mean (and mode)
N (0, τ I), and
of the posterior distribution, under a Gaussian prior β
N (Xβ, σ2I). Find the relationship between
Gaussian sampling model y
the regularization parameter λ in the ridge formula, and the variances τ
and σ2.

∼

∼

N (β0 + xT

i β, σ2), i = 1, 2, . . . , N , and the parameters
Ex. 3.7 Assume yi ∼
βj, j = 1, . . . , p are each distributed as N (0, τ 2), independently of one
another. Assuming σ2 and τ 2 are known, and β0 is not governed by a
prior (or has a ﬂat improper prior), show that the (minus) log-posterior
N
p
j=1 β2
density of β is proportional to
j
where λ = σ2/τ 2.

j xijβj)2 + λ

i=1(yi −

β0 −

P

P

P

Ex. 3.8 Consider the QR decomposition of the uncentered N
(p + 1)
matrix X (whose ﬁrst column is all ones), and the SVD of the N
p
centered matrix ˜X. Show that Q2 and U span the same subspace, where
Q2 is the sub-matrix of Q with the ﬁrst column removed. Under what
circumstances will they be the same, up to sign ﬂips?

×

×

Ex. 3.9 Forward stepwise regression. Suppose we have the QR decomposi-
q matrix X1 in a multiple regression problem with response
tion for the N
×
y, and we have an additional p
q predictors in the matrix X2. Denote the
current residual by r. We wish to establish which one of these additional
variables will reduce the residual-sum-of squares the most when included
with those in X1. Describe an eﬃcient procedure for doing this.

−

Ex. 3.10 Backward stepwise regression. Suppose we have the multiple re-
gression ﬁt of y on X, along with the standard errors and Z-scores as in
Table 3.2. We wish to establish which variable, when dropped, will increase
the residual sum-of-squares the least. How would you do this?

Ex. 3.11 Show that the solution to the multivariate linear regression prob-
lem (3.40) is given by (3.39). What happens if the covariance matrices Σi
are diﬀerent for each observation?

96

3. Linear Methods for Regression

Ex. 3.12 Show that the ridge regression estimates can be obtained by
ordinary least squares regression on an augmented data set. We augment
the centered matrix X with p additional rows √λI, and augment y with p
zeros. By introducing artiﬁcial data having response value zero, the ﬁtting
procedure is forced to shrink the coeﬃcients toward zero. This is related to
the idea of hints due to Abu-Mostafa (1995), where model constraints are
implemented by adding artiﬁcial data examples that satisfy them.

Ex. 3.13 Derive the expression (3.62), and show that ˆβpcr(p) = ˆβls.

Ex. 3.14 Show that in the orthogonal case, PLS stops after m = 1 steps,
because subsequent ˆϕmj in step 2 in Algorithm 3.3 are zero.

Ex. 3.15 Verify expression (3.64), and hence show that the partial least
squares directions are a compromise between the ordinary regression coef-
ﬁcient and the principal component directions.

Ex. 3.16 Derive the entries in Table 3.4, the explicit forms for estimators
in the orthogonal case.

Ex. 3.17 Repeat the analysis of Table 3.3 on the spam data discussed in
Chapter 1.

Ex. 3.18 Read about conjugate gradient algorithms (Murray et al., 1981, for
example), and establish a connection between these algorithms and partial
least squares.

ˆβridge
k

Ex. 3.19 Show that
0. Does
the same property hold for the lasso and partial least squares estimates?
For the latter, consider the “tuning parameter” to be the successive steps
in the algorithm.

increases as its tuning parameter λ

→

k

Ex. 3.20 Consider the canonical-correlation problem (3.67). Show that the
leading pair of canonical variates u1 and v1 solve the problem

max
uT (YT Y)u=1
vT (XT X)v=1

uT (YT X)v,

(3.86)

a generalized SVD problem. Show that the solution is given by u1 =
(YT Y)− 1
1 are the leading left
and right singular vectors in

1, and v1 = (XT X)− 1

1, where u∗

1 and v∗

2 u∗

2 v∗

(YT Y)− 1

2 (YT X)(XT X)− 1

2 = U∗D∗V∗T .

(3.87)

Show that the entire sequence um, vm, m = 1, . . . , min(K, p) is also given
by (3.87).

Ex. 3.21 Show that the solution to the reduced-rank regression problem
(3.68), with Σ estimated by YT Y/N , is given by (3.69). Hint: Transform

Y to Y∗ = YΣ− 1
that Um = Σ− 1
2 U∗

2 , and solved in terms of the canonical vectors u∗
m, and a generalized inverse is U−
2 .

m = U∗
m

T Σ

1

m. Show

Exercises

97

Ex. 3.22 Show that the solution in Exercise 3.21 does not change if Σ is
estimated by the more natural quantity (Y
pK).

X ˆB)T (Y

X ˆB)/(N

−

−

−

Ex. 3.23 Consider a regression problem with all variables and response hav-
ing mean zero and standard deviation one. Suppose also that each variable
has identical absolute correlation with the response:

1
N |h

xj, y

i|

= λ, j = 1, . . . , p.

Let ˆβ be the least-squares coeﬃcient of y on X, and let u(α) = αX ˆβ for
α
[0, 1] be the vector that moves a fraction α toward the least squares ﬁt
u. Let RSS be the residual sum-of-squares from the full least squares ﬁt.

∈

(a) Show that

1
N |h

xj, y

u(α)

i|

−

= (1

−

α)λ, j = 1, . . . , p,

and hence the correlations of each xj with the residuals remain equal
in magnitude as we progress toward u.

(b) Show that these correlations are all equal to

λ(α) =

(1

(1

α)

−
α)2 + α(2−α)

N

−

λ,

RSS ·

·

q
and hence they decrease monotonically to zero.

(c) Use these results to show that the LAR algorithm in Section 3.4.4
keeps the correlations tied and monotonically decreasing, as claimed
in (3.55).

Ex. 3.24 LAR directions. Using the notation around equation (3.55) on
page 74, show that the LAR direction makes an equal angle with each of
the predictors in

Ak.

Ex. 3.25 LAR look-ahead (Efron et al., 2004, Sec. 2). Starting at the be-
ginning of the kth step of the LAR algorithm, derive expressions to identify
the next variable to enter the active set at step k + 1, and the value of α at
which this occurs (using the notation around equation (3.55) on page 74).

Ex. 3.26 Forward stepwise regression enters the variable at each step that
most reduces the residual sum-of-squares. LAR adjusts variables that have
the most (absolute) correlation with the current residuals. Show that these
two entry criteria are not necessarily the same. [Hint: let xj.A be the jth

98

3. Linear Methods for Regression

variable, linearly adjusted for all the variables currently in the model. Show
that the ﬁrst criterion amounts to identifying the j for which Cor(xj.A, r)
is largest in magnitude.

Ex. 3.27 Lasso and LAR: Consider the lasso problem in Lagrange multiplier
form: with L(β) = 1
2

j xijβj)2, we minimize

i(yi −

P

P
L(β) + λ

βj|

|

j
X

(3.88)

for ﬁxed λ > 0.

(a) Setting βj = β+
j(β+
L(β) + λ

j with β+
β−
j −
j + β−
j ). Show that the Lagrange dual function is

0, expression (3.88) becomes

j , β−

j ≥

P

L(β) + λ

(β+

j + β−
j )

j
X

j β+
λ+

j −

−

j
X

j
X

j β−
λ−

j

(3.89)

and the Karush–Kuhn–Tucker optimality conditions are

L(β)j + λ

L(β)j + λ

∇

−∇

−

λ+
j = 0
λ−
j = 0
−
j β+
λ+
j = 0
λ−
j β−
j = 0,

along with the non-negativity constraints on the parameters and all
the Lagrange multipliers.

(b) Show that

L(β)j| ≤
of the following three scenarios:

|∇

λ

∀

j, and that the KKT conditions imply one

λ = 0
β+
j > 0, λ > 0
β−
j > 0, λ > 0

L(β)j = 0
⇒ ∇
λ+
j = 0,
λ−
j = 0,

j
L(β)j =
−
L(β)j = λ > 0, β+

λ < 0, β−

j = 0
j = 0.

⇒

∇

∀

⇒

∇

L(β)j =

= 0, we must
Hence show that for any “active” predictor having βj 6
have
L(β)j = λ if βj < 0. Assuming
λ if βj > 0, and
the predictors are standardized, relate λ to the correlation between
the jth predictor and the current residuals.

∇

∇

−

(c) Suppose that the set of active predictors is unchanged for λ0 ≥

Show that there is a vector γ0 such that

λ

≥

λ1.

ˆβ(λ) = ˆβ(λ0)

(λ

λ0)γ0

(3.90)

−
Thus the lasso solution path is linear as λ ranges from λ0 to λ1(Efron
et al., 2004; Rosset and Zhu, 2007).

−

Exercises

99

Ex. 3.28 Suppose for a given t in (3.51), the ﬁtted lasso coeﬃcient for
variable Xj is ˆβj = a. Suppose we augment our set of variables with an
identical copy X ∗
j = Xj. Characterize the eﬀect of this exact collinearity
by describing the set of solutions for ˆβj and ˆβ∗
j , using the same value of t.

Ex. 3.29 Suppose we run a ridge regression with parameter λ on a single
variable X, and get coeﬃcient a. We now include an exact copy X ∗ = X,
and reﬁt our ridge regression. Show that both coeﬃcients are identical, and
derive their value. Show in general that if m copies of a variable Xj are
included in a ridge regression, their coeﬃcients are all the same.

Ex. 3.30 Consider the elastic-net optimization problem:

y

min

β ||

−

Xβ

||

2 + λ

α

2
2 + (1

β

||

||

α)

β

||

||1

−

.

(3.91)

Show how one can turn this into a lasso problem, using an augmented
version of X and y.

(cid:2)

(cid:3)

100

3. Linear Methods for Regression

4
Linear Methods for Classiﬁcation

This is page 101
Printer: Opaque this

4.1

Introduction

In this chapter we revisit the classiﬁcation problem and focus on linear
methods for classiﬁcation. Since our predictor G(x) takes values in a dis-
crete set
, we can always divide the input space into a collection of regions
labeled according to the classiﬁcation. We saw in Chapter 2 that the bound-
aries of these regions can be rough or smooth, depending on the prediction
function. For an important class of procedures, these decision boundaries
are linear; this is what we will mean by linear methods for classiﬁcation.

G

There are several diﬀerent ways in which linear decision boundaries can
be found. In Chapter 2 we ﬁt linear regression models to the class indicator
variables, and classify to the largest ﬁt. Suppose there are K classes, for
convenience labeled 1, 2, . . . , K, and the ﬁtted linear model for the kth
indicator response variable is ˆfk(x) = ˆβk0 + ˆβT
k x. The decision boundary
between class k and ℓ is that set of points for which ˆfk(x) = ˆfℓ(x), that is,
ˆβℓ)T x = 0
, an aﬃne set or hyperplane.1
the set
}
Since the same is true for any pair of classes, the input space is divided
into regions of constant classiﬁcation, with piecewise hyperplanar decision
boundaries. This regression approach is a member of a class of methods
that model discriminant functions δk(x) for each class, and then classify x
to the class with the largest value for its discriminant function. Methods

ˆβℓ0) + ( ˆβk −

x : ( ˆβk0 −
{

1Strictly speaking, a hyperplane passes through the origin, while an aﬃne set need

not. We sometimes ignore the distinction and refer in general to hyperplanes.

102

4. Linear Methods for Classiﬁcation

that model the posterior probabilities Pr(G = k
class. Clearly, if either the δk(x) or Pr(G = k
the decision boundaries will be linear.

|

X = x) are also in this
X = x) are linear in x, then

|

Actually, all we require is that some monotone transformation of δk or
Pr(G = k
X = x) be linear for the decision boundaries to be linear. For
example, if there are two classes, a popular model for the posterior proba-
bilities is

|

Pr(G = 1
|

X = x) =

Pr(G = 2
|

X = x) =

exp(β0 + βT x)
1 + exp(β0 + βT x)
1
1 + exp(β0 + βT x)

,

.

(4.1)

Here the monotone transformation is the logit transformation: log[p/(1
and in fact we see that

−

p)],

log

Pr(G = 1
|
Pr(G = 2
|

X = x)
X = x)

= β0 + βT x.

(4.2)

The decision boundary is the set of points for which the log-odds are zero,
and this is a hyperplane deﬁned by
. We discuss two very
x
|
popular but diﬀerent methods that result in linear log-odds or logits: linear
discriminant analysis and linear logistic regression. Although they diﬀer in
their derivation, the essential diﬀerence between them is in the way the
linear function is ﬁt to the training data.

β0 + βT x = 0

(cid:8)

(cid:9)

A more direct approach is to explicitly model the boundaries between
the classes as linear. For a two-class problem in a p-dimensional input
space, this amounts to modeling the decision boundary as a hyperplane—in
other words, a normal vector and a cut-point. We will look at two methods
that explicitly look for “separating hyperplanes.” The ﬁrst is the well-
known perceptron model of Rosenblatt (1958), with an algorithm that ﬁnds
a separating hyperplane in the training data, if one exists. The second
method, due to Vapnik (1996), ﬁnds an optimally separating hyperplane if
one exists, else ﬁnds a hyperplane that minimizes some measure of overlap
in the training data. We treat the separable case here, and defer treatment
of the nonseparable case to Chapter 12.

While this entire chapter is devoted to linear decision boundaries, there is
considerable scope for generalization. For example, we can expand our vari-
able set X1, . . . , Xp by including their squares and cross-products X 2
X1X2, . . ., thereby adding p(p + 1)/2 additional variables. Linear functions
in the augmented space map down to quadratic functions in the original
space—hence linear decision boundaries to quadratic decision boundaries.
Figure 4.1 illustrates the idea. The data are the same: the left plot uses
linear decision boundaries in the two-dimensional space shown, while the
right plot uses linear decision boundaries in the augmented ﬁve-dimensional
space described above. This approach can be used with any basis transfor-

1 , X 2

2 , . . . ,

4.2 Linear Regression of an Indicator Matrix

103

1

1
1

1

1
2

2
2

2

2
2

1

2
2

2

1

2

2
2

2
2
2
2
2
2
2
2
1
2
2
2
2
2 2
2
2
2
2
2
2
2
22
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
22
2
2
2
2
2
2
2
2
22
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2 2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
22
2
2
2
2
2
22
2
2
2
2
2
22
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2 2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2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 4.1. The left plot shows some data from three classes, with linear
decision boundaries found by linear discriminant analysis. The right plot shows
quadratic decision boundaries. These were obtained by ﬁnding linear boundaries
in the ﬁve-dimensional space X1, X2, X1X2, X 2
1 , X 2
2 . Linear inequalities in this
space are quadratic inequalities in the original space.

mation h(X) where h : IRp
chapters.

7→

IRq with q > p, and will be explored in later

4.2 Linear Regression of an Indicator Matrix

G

Here each of the response categories are coded via an indicator variable.
has K classes, there will be K such indicators Yk, k = 1, . . . , K,
Thus if
with Yk = 1 if G = k else 0. These are collected together in a vector
Y = (Y1, . . . , YK ), and the N training instances of these form an N
K
indicator response matrix Y. Y is a matrix of 0’s and 1’s, with each row
having a single 1. We ﬁt a linear regression model to each of the columns
of Y simultaneously, and the ﬁt is given by

×

ˆY = X(XT X)−1XT Y.

(4.3)

Chapter 3 has more details on linear regression. Note that we have a coeﬃ-
cient vector for each response column yk, and hence a (p+1)
K coeﬃcient
matrix ˆB = (XT X)−1XT Y. Here X is the model matrix with p+1 columns
corresponding to the p inputs, and a leading column of 1’s for the intercept.

×

A new observation with input x is classiﬁed as follows:

compute the ﬁtted output ˆf (x)T = (1, xT ) ˆB, a K vector;

identify the largest component and classify accordingly:

•

•

ˆG(x) = argmaxk∈G

ˆfk(x).

(4.4)

104

4. Linear Methods for Classiﬁcation

|

|

What is the rationale for this approach? One rather formal justiﬁcation
is to view the regression as an estimate of conditional expectation. For the
X = x), so conditional
random variable Yk, E(Yk|
expectation of each of the Yk seems a sensible goal. The real issue is: how
good an approximation to conditional expectation is the rather rigid linear
regression model? Alternatively, are the ˆfk(x) reasonable estimates of the
posterior probabilities Pr(G = k
X = x), and more importantly, does this
matter?

X = x) = Pr(G = k

It is quite straightforward to verify that

ˆfk(x) = 1 for any x, as
long as there is an intercept in the model (column of 1’s in X). However,
the ˆfk(x) can be negative or greater than 1, and typically some are. This
is a consequence of the rigid nature of linear regression, especially if we
make predictions outside the hull of the training data. These violations in
themselves do not guarantee that this approach will not work, and in fact
on many problems it gives similar results to more standard linear meth-
ods for classiﬁcation. If we allow linear regression onto basis expansions
h(X) of the inputs, this approach can lead to consistent estimates of the
probabilities. As the size of the training set N grows bigger, we adaptively
include more basis elements so that linear regression onto these basis func-
tions approaches conditional expectation. We discuss such approaches in
Chapter 5.

P

k∈G

A more simplistic viewpoint is to construct targets tk for each class,
K identity matrix. Our prediction
where tk is the kth column of the K
problem is to try and reproduce the appropriate target for an observation.
With the same coding as before, the response vector yi (ith row of Y) for
observation i has the value yi = tk if gi = k. We might then ﬁt the linear
model by least squares:

×

min
B

N

i=1
X

yi −

||

[(1, xT

i )B]T

2.

||

(4.5)

The criterion is a sum-of-squared Euclidean distances of the ﬁtted vectors
from their targets. A new observation is classiﬁed by computing its ﬁtted
vector ˆf (x) and classifying to the closest target:

ˆG(x) = argmin

k

ˆf (x)

||

2.

tk||

−

(4.6)

This is exactly the same as the previous approach:

•

The sum-of-squared-norm criterion is exactly the criterion for multi-
ple response linear regression, just viewed slightly diﬀerently. Since
a squared norm is itself a sum of squares, the components decouple
and can be rearranged as a separate linear model for each element.
Note that this is only possible because there is nothing in the model
that binds the diﬀerent responses together.

4.2 Linear Regression of an Indicator Matrix

105

Linear Regression

Linear Discriminant Analysis

3

3

3

3

3

3

3

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
33
3
3
3
3
3
3
3
3
3
3
3
3
3
333
3
3
3
3
33
3
3
3
3
33
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
33
3
3
3
3
3
3
3
3 3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
33
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3 3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
33
33
3
3
3
3
3
3
3
3
3
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2
2
2
2 2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2 2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2

2
2
2

2
2

2

2

2

2
2

1

1

2

2

2
2

2
2
2

2
2
1

3

3

2
2
2
2

2

2

2

2
2

FIGURE 4.2. The data come from three classes in IR2 and are easily separated
by linear decision boundaries. The right plot shows the boundaries found by linear
discriminant analysis. The left plot shows the boundaries found by linear regres-
sion of the indicator response variables. The middle class is completely masked
(never dominates).

•

The closest target classiﬁcation rule (4.6) is easily seen to be exactly
the same as the maximum ﬁtted component criterion (4.4).

≥

There is a serious problem with the regression approach when the number
of classes K
3, especially prevalent when K is large. Because of the rigid
nature of the regression model, classes can be masked by others. Figure 4.2
illustrates an extreme situation when K = 3. The three classes are perfectly
separated by linear decision boundaries, yet linear regression misses the
middle class completely.

In Figure 4.3 we have projected the data onto the line joining the three
centroids (there is no information in the orthogonal direction in this case),
and we have included and coded the three response variables Y1, Y2 and
Y3. The three regression lines (left panel) are included, and we see that
the line corresponding to the middle class is horizontal and its ﬁtted values
are never dominant! Thus, observations from class 2 are classiﬁed either
as class 1 or class 3. The right panel uses quadratic regression rather than
linear regression. For this simple example a quadratic rather than linear
ﬁt (for the middle class at least) would solve the problem. However, it
can be seen that if there were four rather than three classes lined up like
this, a quadratic would not come down fast enough, and a cubic would
be needed as well. A loose but general rule is that if K
3 classes are
≥
lined up, polynomial terms up to degree K
1 might be needed to resolve
them. Note also that these are polynomials along the derived direction
passing through the centroids, which can have arbitrary orientation. So in

−

106

4. Linear Methods for Classiﬁcation

Degree = 1; Error = 0.33

Degree = 2; Error = 0.04

1

1.0

1
1
1
1
1
1
1
1
1

1
11
1

1

1
11
1
11
1
1
1
1
1
1
1
1
1
11
1
1
11
1
1
1
1
1
1
1
11
1
1

1
1

0.5

0.0

2

2
22
2
2
2
2
2
2

2
2
22

2
222
2
2
2 22 2
22
222
22 222
2 2
2
22 2 22
2
2
2 2
2
2
2

3
3

33
3
3
3
3
3
3
33
3
3
33
3
3
3
3
3
3
3
3
3
3
3
3
33
3
33
3

3

3
33
3

3
3
3
3
3
3
3
3
3

3

1

2

3

1
1
1
1
1
11
1
1

33
3
3
3
3
1
33
11
3
333
1
1
3
3
1
11
3
3
1
33
3
11
33
11
1
33
22
1
2
2
22 2
2222 2
1
22
2222 22
222
2
2
2
222
22
22
2
22
3
2
22
3
2
2
2
2
2
3
11
1
3
33
1
1
3
111
33
1
3
11
1
3
1
3
1
1
1
1
3
33
11
3
3
3
3
3
3

3
3

3
3
3
3

3
33
3
33
3
3
3
3
3
3
3
3
3
3
33
33
3
33
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3

3
3
3

3
3

3

3
3
3
3
3
3

2 2
2
2
2
2
2

2
2

2
2
2

2
2
2 2
2
2
2
22
2
2 2
2 2
2
2
222
22
22
2
22
2
2
2 22
22
22
2
2
2 2
2
2

2
2

1
1
1
1
1
1

1

1
1

1
1
1

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
11
11
1
1
1
1
1
1
1
1
1
11
1
1
1
1
11
1

1
1
1
1

1
1

1.0

0.5

0.0

1

3

2

1
1
1
1
1
1
1
1
1

1
11
1

1

1
11
1
11
1
1
1
1
1
1
1
1
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1

2
2
2
2
2
2
2
2
22
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
22
2
22
2

1
1
2
2

2

1

2
2
3
3

3
3
3
2
2
2

2

3

22
222
2222 22
22
222
22 2
2222 2
22
2
2
22
2
2
2
2
22
22
2
2
2
2
2
2

2
2
2
2
2
2

3
3
3
3
3
3

1
1
1
1
1
11
1
1

33
3
1
3
3
3
11
1
1 1
33
3
1
11
333
3
1
3
3
11
33
111
11
1
333
33
33
11
3 3
3
1
111
1
11
1
3
33
1
3
33
1
3
1
1
1
3
11

2
3 3
3
3
33 333
33 3 33
3 3
3
3 33 3
3
333
3
3
333
33
3
3
3

3
33
3
2
22
2

3
33
3
3
3
3
3
3

3

1
1
1
1
1
1

1

1
1

1
1
1

3
3
3
3
3
3
3
3
3

2
2
2
2
2
2
2
2
2

3
3

3
3
3
3

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
1
1 1
2
2
1
1 1
1
11
1
1
2
1 1
1
11
111
11
1 11
1
11
1 1
1
1
11
11
1
1
1
1
2
2
2

2
2
2
2

1
1

2
2

0.0

0.2

0.4

0.6

0.8

1.0

0.0

0.2

0.4

0.6

0.8

1.0

FIGURE 4.3. The eﬀects of masking on linear regression in IR for a three-class
problem. The rug plot at the base indicates the positions and class membership of
each observation. The three curves in each panel are the ﬁtted regressions to the
three-class indicator variables; for example, for the blue class, yblue is 1 for the
blue observations, and 0 for the green and orange. The ﬁts are linear and quadratic
polynomials. Above each plot is the training error rate. The Bayes error rate is
0.025 for this problem, as is the LDA error rate.

p-dimensional input space, one would need general polynomial terms and
1, O(pK−1) terms in all, to resolve such
cross-products of total degree K
worst-case scenarios.

−

The example is extreme, but for large K and small p such maskings
naturally occur. As a more realistic illustration, Figure 4.4 is a projection
of the training data for a vowel recognition problem onto an informative
two-dimensional subspace. There are K = 11 classes in p = 10 dimensions.
This is a diﬃcult classiﬁcation problem, and the best methods achieve
around 40% errors on the test data. The main point here is summarized in
Table 4.1; linear regression has an error rate of 67%, while a close relative,
linear discriminant analysis, has an error rate of 56%. It seems that masking
has hurt in this case. While all the other methods in this chapter are based
on linear functions of x as well, they use them in such a way that avoids
this masking problem.

4.3 Linear Discriminant Analysis

Decision theory for classiﬁcation (Section 2.4) tells us that we need to know
the class posteriors Pr(G
X) for optimal classiﬁcation. Suppose fk(x) is
|
the class-conditional density of X in class G = k, and let πk be the prior
K
probability of class k, with
k=1 πk = 1. A simple application of Bayes

P

4.3 Linear Discriminant Analysis

107

Linear Discriminant Analysis

oooooo

oo
o
o

o
o
o oooo
oo
o

ooo

o

ooo
o
ooo

••

ooo
ooooo o
o o
o
o
o
o
o
o
o
o
oo
o o
o o
ooo
o
o
o
o
o
oo
o
ooo
o
ooo
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
oo
oo
o
o
oo
o
o
o
o oo
o
o
o
oo
o
o
ooo
o
o
o
o
o
oo
o oo
ooo oo
o
o
o
o
o
ooo
oooo
o
o
o
o
o
o
o
o
oo

••
••

o

o

o

o

o

o

oo
o
o
o

o

o

o

o

o
o

o
o

oo

ooo
o

o

oo
oo oo
o
ooooo

o

o

o oooo
o
o
ooo
o
ooo
o
o
o
o o
o
o

o

o
o
oo

o

o

o
oo
o
o

oo
o

o

••

o
o
o
o
o
o
o
o
o
o
ooo
o
oo
o
o
ooo
o
o

o

••

o
o
o
oo
o
o
oo
o
o
o
oo
o
oo
o
ooo
o
o
oo
oo
o
o
o
o
o
o
o

••

o

o

o

ooo
o o
o

o
o

o

o

o oo
o o
o
oo
o
o
o
o
o
o
o
oo o
o
oo
o
oo
o
o
o
o
o

••

o
o
o
oo
oo
o
o
o
o
o
o
o
ooo

o
o

o o o
o
o

o
o
o
o
oo

o

o

o

o

o

o
o

o

o

0

Coordinate 1 for Training Data

2

4

4

2

0

2
-

4
-

6
-

i

a
t
a
D
g
n
n
a
r
T
r
o
f

i

2

i

e
t
a
n
d
r
o
o
C

oo
ooo o

ooooo
o

ooooo

o
ooooo
o

o

••

oo
ooo
oooooo
o
ooo
o
o
oo
o

••

oooo
o
o
o
ooo
o
o
oo
ooo
o
o
ooo
oo
oo
o
oo
o
o
o
ooo
o
o
o o
o
o
o
o
o
o
o
o
o
oo
o
o

oo
o
o

••
••

o

o

o

o
oooo
o

o o

o

o

o
o
ooo

o

o

o
o

o o

o
o

o

o
o
oo o
oo
o
o
oo
o
o
oo o

oo

o oo
o

o

o

o o o
o
o

oo

o

o

-4

-2

FIGURE 4.4. A two-dimensional plot of the vowel training data. There are
IR10, and this is the best view in terms of a LDA model
eleven classes with X
(Section 4.3.3). The heavy circles are the projected mean vectors for each class.
The class overlap is considerable.

∈

TABLE 4.1. Training and test error rates using a variety of linear techniques
on the vowel data. There are eleven classes in ten dimensions, of which three
account for 90% of the variance (via a principal components analysis). We see
that linear regression is hurt by masking, increasing the test and training error
by over 10%.

Technique

Linear regression
Linear discriminant analysis
Quadratic discriminant analysis
Logistic regression

Error Rates
Training Test
0.67
0.48
0.56
0.32
0.53
0.01
0.51
0.22

 
 
 
 
108

4. Linear Methods for Classiﬁcation

theorem gives us

Pr(G = k

|

X = x) =

fk(x)πk
K
ℓ=1 fℓ(x)πℓ

.

(4.7)

We see that in terms of ability to classify, having the fk(x) is almost equiv-
alent to having the quantity Pr(G = k

X = x).

P

Many techniques are based on models for the class densities:

|

•

•

•

•

linear and quadratic discriminant analysis use Gaussian densities;

more ﬂexible mixtures of Gaussians allow for nonlinear decision bound-
aries (Section 6.8);

general nonparametric density estimates for each class density allow
the most ﬂexibility (Section 6.6.2);

Naive Bayes models are a variant of the previous case, and assume
that each of the class densities are products of marginal densities;
that is, they assume that the inputs are conditionally independent in
each class (Section 6.6.3).

Suppose that we model each class density as multivariate Gaussian

fk(x) =

1
(2π)p/2

|

Σk|

1/2 e− 1

2 (x−µk)T Σ−1

k (x−µk).

(4.8)

Linear discriminant analysis (LDA) arises in the special case when we
assume that the classes have a common covariance matrix Σk = Σ
k. In
comparing two classes k and ℓ, it is suﬃcient to look at the log-ratio, and
we see that

∀

log

µℓ)

(4.9)

+ log

= log

= log

πk
πℓ

Pr(G = k
Pr(G = ℓ

X = x)
|
X = x)
|

(µk + µℓ)T Σ−1(µk −
µℓ),

fk(x)
fℓ(x)
1
πk
πℓ −
2
+ xT Σ−1(µk −
an equation linear in x. The equal covariance matrices cause the normal-
ization factors to cancel, as well as the quadratic part in the exponents.
This linear log-odds function implies that the decision boundary between
classes k and ℓ—the set where Pr(G = k
X = x)—is
linear in x; in p dimensions a hyperplane. This is of course true for any pair
of classes, so all the decision boundaries are linear. If we divide IRp into
regions that are classiﬁed as class 1, class 2, etc., these regions will be sep-
arated by hyperplanes. Figure 4.5 (left panel) shows an idealized example
with three classes and p = 2. Here the data do arise from three Gaus-
sian distributions with a common covariance matrix. We have included in

X = x) = Pr(G = ℓ

|

|

4.3 Linear Discriminant Analysis

109

+

+

+

3
1

1

3
3

1
1
1

3
1
3

3

1
3
3
3
3
2
1
1

3
3
3
1

1
3

1
3
3
3
3
3
1
3
3
3
1
2
2
1 2
2
3
2
1

2

2

3
3

2

3

2
2
2
2
2

2
2

3

2

2

2

2

2

2 2

2

1

3

1
1
3
1
1
3
1
1
1
1
1
1
1

1

2
1

2

2
2

2

2

FIGURE 4.5. The left panel shows three Gaussian distributions, with the same
covariance and diﬀerent means. Included are the contours of constant density
enclosing 95% of the probability in each case. The Bayes decision boundaries
between each pair of classes are shown (broken straight lines), and the Bayes
decision boundaries separating all three classes are the thicker solid lines (a subset
of the former). On the right we see a sample of 30 drawn from each Gaussian
distribution, and the ﬁtted LDA decision boundaries.

the ﬁgure the contours corresponding to 95% highest probability density,
as well as the class centroids. Notice that the decision boundaries are not
the perpendicular bisectors of the line segments joining the centroids. This
would be the case if the covariance Σ were spherical σ2I, and the class
priors were equal. From (4.9) we see that the linear discriminant functions

δk(x) = xT Σ−1µk −

1
2

k Σ−1µk + log πk
µT

(4.10)

are an equivalent description of the decision rule, with G(x) = argmaxkδk(x).
In practice we do not know the parameters of the Gaussian distributions,

and will need to estimate them using our training data:

ˆπk = Nk/N , where Nk is the number of class-k observations;

ˆµk =

gi=k xi/Nk;

ˆΣ =

P
K
k=1

gi=k(xi −

ˆµk)(xi −

ˆµk)T /(N

K).

−

•

•

•

P

Figure 4.5 (right panel) shows the estimated decision boundaries based on
a sample of size 30 each from three Gaussian distributions. Figure 4.1 on
page 103 is another example, but here the classes are not Gaussian.

P

With two classes there is a simple correspondence between linear dis-
criminant analysis and classiﬁcation by linear regression, as in (4.5). The
LDA rule classiﬁes to class 2 if

−1

xT ˆΣ

(ˆµ2 −

ˆµ1) >

1
2

(ˆµ2 + ˆµ1)T ˆΣ

−1

(ˆµ2 −

ˆµ1)

−

log(N2/N1),

(4.11)

110

4. Linear Methods for Classiﬁcation

−

and class 1 otherwise. Suppose we code the targets in the two classes as +1
1, respectively. It is easy to show that the coeﬃcient vector from least
and
squares is proportional to the LDA direction given in (4.11) (Exercise 4.2).
[In fact, this correspondence occurs for any (distinct) coding of the targets;
see Exercise 4.2]. However unless N1 = N2 the intercepts are diﬀerent and
hence the resulting decision rules are diﬀerent.

Since this derivation of the LDA direction via least squares does not use a
Gaussian assumption for the features, its applicability extends beyond the
realm of Gaussian data. However the derivation of the particular intercept
or cut-point given in (4.11) does require Gaussian data. Thus it makes
sense to instead choose the cut-point that empirically minimizes training
error for a given dataset. This is something we have found to work well in
practice, but have not seen it mentioned in the literature.

With more than two classes, LDA is not the same as linear regression of
the class indicator matrix, and it avoids the masking problems associated
with that approach (Hastie et al., 1994). A correspondence between regres-
sion and LDA can be established through the notion of optimal scoring,
discussed in Section 12.5.

Getting back to the general discriminant problem (4.8), if the Σk are
not assumed to be equal, then the convenient cancellations in (4.9) do not
occur; in particular the pieces quadratic in x remain. We then get quadratic
discriminant functions (QDA),

δk(x) =

1
2

−

log

Σk| −

|

1
2

(x

−

µk)T Σ−1

k (x

−

µk) + log πk.

(4.12)

x : δk(x) = δℓ(x)
{

.
}

The decision boundary between each pair of classes k and ℓ is described by
a quadratic equation

Figure 4.6 shows an example (from Figure 4.1 on page 103) where the
three classes are Gaussian mixtures (Section 6.8) and the decision bound-
aries are approximated by quadratic equations in x. Here we illustrate
two popular ways of ﬁtting these quadratic boundaries. The right plot
uses QDA as described here, while the left plot uses LDA in the enlarged
ﬁve-dimensional quadratic polynomial space. The diﬀerences are generally
small; QDA is the preferred approach, with the LDA method a convenient
substitute 2.

The estimates for QDA are similar to those for LDA, except that separate
covariance matrices must be estimated for each class. When p is large this
can mean a dramatic increase in parameters. Since the decision boundaries
are functions of the parameters of the densities, counting the number of
parameters must be done with care. For LDA, it seems there are (K
(p + 1) parameters, since we only need the diﬀerences δk(x)
1)

−
δK(x)

×

−

2For this ﬁgure and many similar ﬁgures in the book we compute the decision bound-
aries by an exhaustive contouring method. We compute the decision rule on a ﬁne lattice
of points, and then use contouring algorithms to compute the boundaries.

1

1
1

1

1
2

2
2

2

2
2

1

2
2

2

1

2

2
2

2
2
2
2
2
2
2
2
1
2
2
2
2
2 2
2
2
2
2
2
2
2
22
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
22
2
2
2
2
2
2
2
2
22
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2 2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
22
2
2
2
2
2
22
2
2
2
2
2
22
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2 2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
1
2
2
2
2
2
2
2
1
1
2
1
1
2
2
2
2
1
1
2
1
2
2
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1

1
2

2

1

1

2

1

1

1

1

1

1
1

1

2
2
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

1
1
1
1
1

1
1

1
1

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1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1

1

2
2
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

1
1
1
1
1

1
1

1
1

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

1

1

1

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

1

2

2
2
2
2
2
2
2
2

2

2

2

1
1

1

1

1

3

3
3
3
3
3

3

3
3
3
3

3
3

3

1

3
1
3
3
1
1
1

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
3

1
1
1
1
1
1
1

1

1

1

3

3

1
1

3
3
3
3
3
3
3
33
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
1
3
3
3
3
3
3
3
3
1
3
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
33
1
3
3
3
3
3
3
1
3
3
3
3
3
3
3
3
3
3 3
3
3
3
33
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
1
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3 3
3
3
3
3
3
3
1
3
3
3 3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
33
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3

FIGURE 4.6. Two methods for ﬁtting quadratic boundaries. The left plot shows
the quadratic decision boundaries for the data in Figure 4.1 (obtained using LDA
in the ﬁve-dimensional space X1, X2, X1X2, X 2
2 ). The right plot shows the
quadratic decision boundaries found by QDA. The diﬀerences are small, as is
usually the case.

1 , X 2

1)

× {

p(p + 3)/2 + 1
}

between the discriminant functions where K is some pre-chosen class (here
we have chosen the last), and each diﬀerence requires p + 1 parameters3.
Likewise for QDA there will be (K
parameters.
−
Both LDA and QDA perform well on an amazingly large and diverse set
of classiﬁcation tasks. For example, in the STATLOG project (Michie et
al., 1994) LDA was among the top three classiﬁers for 7 of the 22 datasets,
QDA among the top three for four datasets, and one of the pair were in the
top three for 10 datasets. Both techniques are widely used, and entire books
are devoted to LDA. It seems that whatever exotic tools are the rage of the
day, we should always have available these two simple tools. The question
arises why LDA and QDA have such a good track record. The reason is not
likely to be that the data are approximately Gaussian, and in addition for
LDA that the covariances are approximately equal. More likely a reason is
that the data can only support simple decision boundaries such as linear or
quadratic, and the estimates provided via the Gaussian models are stable.
This is a bias variance tradeoﬀ—we can put up with the bias of a linear
decision boundary because it can be estimated with much lower variance
than more exotic alternatives. This argument is less believable for QDA,
since it can have many parameters itself, although perhaps fewer than the
non-parametric alternatives.

3Although we ﬁt the covariance matrix ˆΣ to compute the LDA discriminant functions,
a much reduced function of it is all that is required to estimate the O(p) parameters
needed to compute the decision boundaries.

112

4. Linear Methods for Classiﬁcation

e
t
a
R
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

i

l

Regularized Discriminant Analysis on the Vowel Data

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

•

•

• • • • • •

Test Data
Train Data

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

0.0

0.2

0.4

0.6

0.8

1.0

α

5
.
0

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

FIGURE 4.7. Test and training errors for the vowel data, using regularized
discriminant analysis with a series of values of α
[0, 1]. The optimum for the
test data occurs around α = 0.9, close to quadratic discriminant analysis.

∈

4.3.1 Regularized Discriminant Analysis

Friedman (1989) proposed a compromise between LDA and QDA, which
allows one to shrink the separate covariances of QDA toward a common
covariance as in LDA. These methods are very similar in ﬂavor to ridge
regression. The regularized covariance matrices have the form

ˆΣk(α) = α ˆΣk + (1

α) ˆΣ,

−

(4.13)

where ˆΣ is the pooled covariance matrix as used in LDA. Here α
[0, 1]
allows a continuum of models between LDA and QDA, and needs to be
speciﬁed. In practice α can be chosen based on the performance of the
model on validation data, or by cross-validation.

∈

Figure 4.7 shows the results of RDA applied to the vowel data. Both
the training and test error improve with increasing α, although the test
error increases sharply after α = 0.9. The large discrepancy between the
training and test error is partly due to the fact that there are many repeat
measurements on a small number of individuals, diﬀerent in the training
and test set.

Similar modiﬁcations allow ˆΣ itself to be shrunk toward the scalar

covariance,

ˆΣ(γ) = γ ˆΣ + (1

γ)ˆσ2I

−

(4.14)

[0, 1]. Replacing ˆΣ in (4.13) by ˆΣ(γ) leads to a more general family

for γ
of covariances ˆΣ(α, γ) indexed by a pair of parameters.

∈

In Chapter 12, we discuss other regularized versions of LDA, which are
more suitable when the data arise from digitized analog signals and images.

 
4.3 Linear Discriminant Analysis

113

In these situations the features are high-dimensional and correlated, and the
LDA coeﬃcients can be regularized to be smooth or sparse in the original
domain of the signal. This leads to better generalization and allows for
easier interpretation of the coeﬃcients. In Chapter 18 we also deal with
very high-dimensional problems, where for example the features are gene-
expression measurements in microarray studies. There the methods focus
on the case γ = 0 in (4.14), and other severely regularized versions of LDA.

4.3.2 Computations for LDA

As a lead-in to the next topic, we brieﬂy digress on the computations
required for LDA and especially QDA. Their computations are simpliﬁed
by diagonalizing ˆΣ or ˆΣk. For the latter, suppose we compute the eigen-
decomposition for each ˆΣk = UkDkUT
p orthonormal,
and Dk a diagonal matrix of positive eigenvalues dkℓ. Then the ingredients
for δk(x) (4.12) are

k , where Uk is p

×

(x

ˆµk)T ˆΣ

−1
k (x

−

ˆµk) = [UT

k (x

−

ˆµk)]T D−1

k [UT

k (x

ˆµk)];

−

•

•

−
ˆΣk|

|

log

=

ℓ log dkℓ.

In light of the computational steps outlined above, the LDA classiﬁer

P

can be implemented by the following pair of steps:

•

Sphere the data with respect to the common covariance estimate ˆΣ:
2 UT X, where ˆΣ = UDUT . The common covariance esti-
X ∗
mate of X ∗ will now be the identity.

D− 1

←

•

Classify to the closest class centroid in the transformed space, modulo
the eﬀect of the class prior probabilities πk.

4.3.3 Reduced-Rank Linear Discriminant Analysis

So far we have discussed LDA as a restricted Gaussian classiﬁer. Part of
its popularity is due to an additional restriction that allows us to view
informative low-dimensional projections of the data.

−

≤

K

The K centroids in p-dimensional input space lie in an aﬃne subspace
of dimension
1, and if p is much larger than K, this will be a con-
siderable drop in dimension. Moreover, in locating the closest centroid, we
can ignore distances orthogonal to this subspace, since they will contribute
equally to each class. Thus we might just as well project the X ∗ onto this
centroid-spanning subspace HK−1, and make distance comparisons there.
Thus there is a fundamental dimension reduction in LDA, namely, that we
1.
need only consider the data in a subspace of dimension at most K

−

114

4. Linear Methods for Classiﬁcation

If K = 3, for instance, this could allow us to view the data in a two-
dimensional plot, color-coding the classes. In doing so we would not have
relinquished any of the information needed for LDA classiﬁcation.

−

What if K > 3? We might then ask for a L < K

1 dimensional subspace
HK−1 optimal for LDA in some sense. Fisher deﬁned optimal to
HL ⊆
mean that the projected centroids were spread out as much as possible in
terms of variance. This amounts to ﬁnding principal component subspaces
of the centroids themselves (principal components are described brieﬂy in
Section 3.5.1, and in more detail in Section 14.5.1). Figure 4.4 shows such an
optimal two-dimensional subspace for the vowel data. Here there are eleven
classes, each a diﬀerent vowel sound, in a ten-dimensional input space. The
centroids require the full space in this case, since K
1 = p, but we have
shown an optimal two-dimensional subspace. The dimensions are ordered,
so we can compute additional dimensions in sequence. Figure 4.8 shows four
additional pairs of coordinates, also known as canonical or discriminant
variables.
In summary then, ﬁnding the sequences of optimal subspaces
for LDA involves the following steps:

−

•

•

•

compute the K
covariance matrix W (for within-class covariance);

p matrix of class centroids M and the common

×

compute M∗ = MW− 1

2 using the eigen-decomposition of W;

compute B∗, the covariance matrix of M∗ (B for between-class covari-
ance), and its eigen-decomposition B∗ = V∗DBV∗T . The columns
v∗
ℓ of V∗ in sequence from ﬁrst to last deﬁne the coordinates of the
optimal subspaces.

Combining all these operations the ℓth discriminant variable is given by
Zℓ = vT

ℓ X with vℓ = W− 1

2 v∗
ℓ .

Fisher arrived at this decomposition via a diﬀerent route, without refer-

ring to Gaussian distributions at all. He posed the problem:

Find the linear combination Z = aT X such that the between-
class variance is maximized relative to the within-class variance.

Again, the between class variance is the variance of the class means of
Z, and the within class variance is the pooled variance about the means.
Figure 4.9 shows why this criterion makes sense. Although the direction
joining the centroids separates the means as much as possible (i.e., max-
imizes the between-class variance), there is considerable overlap between
the projected classes due to the nature of the covariances. By taking the
covariance into account as well, a direction with minimum overlap can be
found.

The between-class variance of Z is aT Ba and the within-class variance
aT Wa, where W is deﬁned earlier, and B is the covariance matrix of the
class centroid matrix M. Note that B + W = T, where T is the total
covariance matrix of X, ignoring class information.

4.3 Linear Discriminant Analysis

115

Linear Discriminant Analysis

o

o

o

o

o

o

o
o

o

o

o
o

o

o

o

o

o

o

ooo

o

o
o
o
ooo
oo
o
o
o
oo
o
o
o o
o
o
o
o
o
o
o
oo
o
o

o
o
o
o

oo
o
o
oo

oo
o

o

o

o

o

o o
o

o

o

o

o
o
o
o
o
o
oo
o
o
oo
o
o
o o
o
o
oo
o
o
o

o
o
o
o
o oo

o

o

o

o
o

••••••
••

o
oo
o
oo
o
oo
o
o o o
o
o
oo oo
o
oooo
o
o
o
o
o
o
oooo
o
o
o
oo
o oooo
o
o
o
o
o
o
o
o
oo
o
o
ooo
o
o
o oo
oo
o
o
o
o
ooo
o
oo
o
o
oo
o
o
o
ooo
oo
o
o
o
o
o
oo
oo o
o
o
o
o
o
oo
o
o
oo
o
oo
o
oo
o o o
ooo
oo
o
o
o
o
o
o
o
oo
oo
o
oo
o
o
o
o
o
o
o
o
oo
o o
o
o
o
oo
o
o
o
oo
o
o
o
o
oooo
ooo
o
o
ooo
o
o
o
o
oooo
o
o
oo
o
o
oo
o
oo
o o
o
o
o
o
o o
o
o
oo
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o o
o
o
o
o
oo
o
o
o o
ooo
o
o
o
o
o
o
oo
o
o
ooo
oo
o o
o
o
o
oo
o
o
o
o
oo
o
o
o
ooo
oo
o
o
o
o
o
o
oooo
oo
oo
oo
o
oo
o
oo
oo
o
o
o
o
o
o
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
o
o
o
o
o
o
o
oo
oo

•• ••
••••••••••••
••

••

••

o
o
oo
oo
o

o
o
o
o

o
o
o
o
o
o

o
o

o
o
o

o
o

o
o

o

o

o

o

o

o
ooo
o
o
o
o
o
o

oo

o
o
oo
oo

o
ooooo

o

o

o

oo

o

o

o

o

o

o

o

-4

o

o

o

-4

-2

0

2

4

-6

-2

0

2

4

Coordinate 1 

o
o
o
o o
o

o

o

o

o

o
o
oo
o
o
ooooo o

o

o
o

o
o
o

o

o

o

o

o

o
o

oo

o
o

ooo
o
o
o
o
ooo
o
o
o
o
o
o
o
ooo
ooo
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
oo
o
ooo
o
o
o
oo
o
o
o oo
oo
o
o
ooo
oooo
o
o
o
ooo
ooo o o
o o
oo
oooooo
o
o
o
o
o
o
o
o
oo
o
oo
o
o
o
oo
oo
o
o
oo
o
ooo
o
o
o
oo
o
o
oooo
o
o
o oo
o
o
o
o
oo
oo
o
o
o o oo
o
o
ooo
o
o
o
o o
o
o o
o
o
oo
o
o
o
o
oo
o
o
o
o o
o
oo
ooo
o
o
o
ooo
o
o
ooo
oo
oo
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
oo
o
o
o
o
oo
o
o
oooooo
oo
o
ooo
o ooo
oo
o
oooo
o
o
o
o
oo
o o oo
o
o
o
o
ooo
o
o
o
o
o
o
o
o
oo
o
o
o
o
ooooo
oo
o
oo
o
o
o
o
oooo
o
oo
o
o o
oo
o o
o
o
o
o
o
o
oo
o
o
oooo
oo
oo
o
o o
o
o
o
o
o
o
o
o
oo
oo
o
o
o o
o
o
o
o
o
o
o
o
oo oo
o
o
o
o
oo
o oo
o
o
o
oo
ooo
oo
o
o
o
oo
o
ooo
o
o
oo
oo
o
o
ooo
o
o
ooo
o oooo
ooo
oo
o
o o
o
o
o
oo
o
o
o
oooo
o
o
o
o
o
o
o
o
o

•••• ••
••

••
••••

••••••••

o
o
oo

o
o
o
o

o o

o
o

o
o

o
o

o
o

o
o

o

o

o

o

o

o

o

o

oo
oo

o o
o
o

o

o

t

0
1
e
a
n
d
r
o
o
C

i

2

1

0

1
-

2
-

Coordinate 2 

o
o

o

o

o

o
o

o

o

o

o

o o
o
o
o

o

o

o

o
oo
o

oooo
o
o o
o
o

o

o

o

o o

o

o
o

oo
o
o
o

o
o
oo

o
o
o

o

o

oo
o
o
o
o
o

o

o

o

o

o

o

o

o
o

o
o

o
o
o

o
o

o o o

o
o
o o
o
o

o
o
oo
o
o
o
o
o

oooo
o o
o
o
o
o
o
oo o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo o
o
o
o o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
ooooo
o
o
o oo
o
o
oo
o
oo
o
o
o
o
o
o
o o
o o
o
o
o
o
o o
o
o
o
o
o oo
oo
oo
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
oo
o
o
o
o
ooo
oo
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oooo
oooo
o
o
o
o
o
oo
oo
o
o o
o o o
o
oo
ooo
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
oo
oo o
o
o
o
oo
o
o
oo
o
o
o
oo
o
o
o o
o
oo
o
oo
o
o
oooo
o
o
o
o
o
o
o
o
o o
o
ooo
o o
oo
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
oo
oo
oo
oo
o
o
o
oo
o
o
o oo
o
o o
o
o
o
o
o
o
o
o o
ooo
o
o
o o
o
oooo
ooo
o
o
o
o
o
o
o
oo
o
o
o
oo
oo
o
o
o
o
oo
o
oo
o
o
oo
o
o
oo
o o
o
o
o
o
o
o
oooooo
oo o
o
o
o

o••••••••••••••••••••••

o
o
o
o
oo
o
o

o
o

o
o

o
o

oo
o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

ooo
o
oo

3

i

e
t
a
n
d
r
o
o
C

t

7
e
a
n
d
r
o
o
C

i

2

0

2
-

3

2

1

0

1
-

2
-

3
-

-4

-2

0

2

4

-2

-1

0

1

2

3

Coordinate 1 

Coordinate 9 

FIGURE 4.8. Four projections onto pairs of canonical variates. Notice that as
the rank of the canonical variates increases, the centroids become less spread out.
In the lower right panel they appear to be superimposed, and the classes most
confused.

 
 
 
 
 
 
 
 
116

4. Linear Methods for Classiﬁcation

+

+

+

+

FIGURE 4.9. Although the line joining the centroids deﬁnes the direction of
greatest centroid spread, the projected data overlap because of the covariance
(left panel). The discriminant direction minimizes this overlap for Gaussian data
(right panel).

Fisher’s problem therefore amounts to maximizing the Rayleigh quotient,

max
a

aT Ba
aT Wa

,

or equivalently

aT Ba subject to aT Wa = 1.

max
a

(4.15)

(4.16)

This is a generalized eigenvalue problem, with a given by the largest
eigenvalue of W−1B. It is not hard to show (Exercise 4.1) that the optimal
a1 is identical to v1 deﬁned above. Similarly one can ﬁnd the next direction
a2, orthogonal in W to a1, such that aT
2 Wa2 is maximized; the
solution is a2 = v2, and so on. The aℓ are referred to as discriminant
coordinates, not to be confused with discriminant functions. They are also
referred to as canonical variates, since an alternative derivation of these
results is through a canonical correlation analysis of the indicator response
matrix Y on the predictor matrix X. This line is pursued in Section 12.5.

2 Ba2/aT

To summarize the developments so far:

•

•

•

Gaussian classiﬁcation with common covariances leads to linear deci-
sion boundaries. Classiﬁcation can be achieved by sphering the data
with respect to W, and classifying to the closest centroid (modulo
log πk) in the sphered space.

Since only the relative distances to the centroids count, one can con-
ﬁne the data to the subspace spanned by the centroids in the sphered
space.

This subspace can be further decomposed into successively optimal
subspaces in term of centroid separation. This decomposition is iden-
tical to the decomposition due to Fisher.

4.3 Linear Discriminant Analysis

117

LDA and Dimension Reduction on the Vowel Data

•

•

7
.
0

6
.
0

5
.
0

4
.
0

3
.
0

•

•

•

•

2

•

•

•

•

4

•

•

•

•

•

Test Data
Train Data

•

•

6

•

8

•

•

10

Dimension

e
t
a
R
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

l

i

FIGURE 4.10. Training and test error rates for the vowel data, as a function
of the dimension of the discriminant subspace. In this case the best error rate is
for dimension 2. Figure 4.11 shows the decision boundaries in this space.

The reduced subspaces have been motivated as a data reduction (for
viewing) tool. Can they also be used for classiﬁcation, and what is the
rationale? Clearly they can, as in our original derivation; we simply limit
the distance-to-centroid calculations to the chosen subspace. One can show
that this is a Gaussian classiﬁcation rule with the additional restriction
that the centroids of the Gaussians lie in a L-dimensional subspace of IRp.
Fitting such a model by maximum likelihood, and then constructing the
posterior probabilities using Bayes’ theorem amounts to the classiﬁcation
rule described above (Exercise 4.8).

Gaussian classiﬁcation dictates the log πk correction factor in the dis-
tance calculation. The reason for this correction can be seen in Figure 4.9.
The misclassiﬁcation rate is based on the area of overlap between the two
densities. If the πk are equal (implicit in that ﬁgure), then the optimal
cut-point is midway between the projected means. If the πk are not equal,
moving the cut-point toward the smaller class will improve the error rate.
As mentioned earlier for two classes, one can derive the linear rule using
LDA (or any other method), and then choose the cut-point to minimize
misclassiﬁcation error over the training data.

As an example of the beneﬁt of the reduced-rank restriction, we return
to the vowel data. There are 11 classes and 10 variables, and hence 10
possible dimensions for the classiﬁer. We can compute the training and
test error in each of these hierarchical subspaces; Figure 4.10 shows the
results. Figure 4.11 shows the decision boundaries for the classiﬁer based
on the two-dimensional LDA solution.

There is a close connection between Fisher’s reduced rank discriminant
analysis and regression of an indicator response matrix. It turns out that

 
118

4. Linear Methods for Classiﬁcation

Classification in Reduced Subspace

o
o
o
o
o
o

o
o
o
o

o
o
o
o
o
o
o

o
o
o

o

o

o
o
o
o
o

o
o
o
o

o
o
o
o
o
o
o

••

o
o
o
o
o
o
oo
o

o

o
o

o
o
o
o

o

o

o

o

o
o

o
o

o
o
o
o

o

o
o
o
o
o
o
o
o
o
o

o
o
o
o

o

o
o

o

o

o

o

o

o
o
o
o
o

o

o

o
o
o

o

o
o
o
o
o
o
o
o

o
o

o
o
o
o
o

o

o

o
o
o
o
o
o
o
o
o
o

••

o
o

o
o
o
o
o

o
o
o
o
o
o
o

o

o
o
o

o
o
o
o
o
o

o
o

o

o
o

o

o

••

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

••

o

o

o

o
o
o
o
o
o

o

o

o

o

o
o
o

o

o
o
o
o

o
o

o
o
o
o
o
o

o
o
o
o

o

o
o
o
o
o
o
o

o

o

o

o

o

o
o
o
o

o

o

o
o

o

o

o
o

o
o
o
o
o
o
o

o
o

o

o
o
o
o
o
o

o
o

o
o

2
e
t
a
n
d
r
o
o
C

i

l

i

a
c
n
o
n
a
C

o
o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

••

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o
o
o
o
o
o
o
o
o

••

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o
o
o

o

o

o

o

o
o
o
o
o
o
o
o
o
o
o
o

o
o
o
o
o
o
o

••

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

••
••

o
o
o
o
o
o

o

o
o
o
o
o

o

o

o

o
o
o

o
o
o
o
o
o

••
••

o

o

o
o
o
o
o

o
o
o
o
o
o
o
o
o
o
o
o

o

o

o

o
o

o

o

Canonical Coordinate 1

FIGURE 4.11. Decision boundaries for the vowel training data, in the two-di-
mensional subspace spanned by the ﬁrst two canonical variates. Note that in
any higher-dimensional subspace, the decision boundaries are higher-dimensional
aﬃne planes, and could not be represented as lines.

 
 
4.4 Logistic Regression

119

LDA amounts to the regression followed by an eigen-decomposition of
ˆYT Y. In the case of two classes, there is a single discriminant variable
that is identical up to a scalar multiplication to either of the columns of ˆY.
These connections are developed in Chapter 12. A related fact is that if one
transforms the original predictors X to ˆY, then LDA using ˆY is identical
to LDA in the original space (Exercise 4.3).

4.4 Logistic Regression

The logistic regression model arises from the desire to model the posterior
probabilities of the K classes via linear functions in x, while at the same
time ensuring that they sum to one and remain in [0, 1]. The model has
the form

log

log

X = x)
Pr(G = 1
|
Pr(G = K
X = x)
|
X = x)
Pr(G = 2
|
X = x)
Pr(G = K
|

= β10 + βT

1 x

= β20 + βT

2 x

...

log

Pr(G = K

−
Pr(G = K
|

X = x)

1
|
X = x)

= β(K−1)0 + βT

K−1x.

(4.17)

The model is speciﬁed in terms of K
1 log-odds or logit transformations
−
(reﬂecting the constraint that the probabilities sum to one). Although the
model uses the last class as the denominator in the odds-ratios, the choice
of denominator is arbitrary in that the estimates are equivariant under this
choice. A simple calculation shows that

Pr(G = k

|

X = x) =

1 +

exp(βk0 + βT
K−1
ℓ=1 exp(βℓ0 + βT

k x)

ℓ x)

Pr(G = K

|

X = x) =

P

1 +

1

K−1
ℓ=1 exp(βℓ0 + βT

ℓ x)

, k = 1, . . . , K

1,

−

,

(4.18)

and they clearly sum to one. To emphasize the dependence on the entire pa-
, we denote the probabilities
rameter set θ =
Pr(G = k

P
1 , . . . , β(K−1)0, βT

β10, βT
{

X = x) = pk(x; θ).

K−1}

When K = 2, this model is especially simple, since there is only a single
linear function. It is widely used in biostatistical applications where binary
responses (two classes) occur quite frequently. For example, patients survive
or die, have heart disease or not, or a condition is present or absent.

|

120

4. Linear Methods for Classiﬁcation

4.4.1 Fitting Logistic Regression Models

Logistic regression models are usually ﬁt by maximum likelihood, using the
conditional likelihood of G given X. Since Pr(G
X) completely speciﬁes the
|
conditional distribution, the multinomial distribution is appropriate. The
log-likelihood for N observations is

N

ℓ(θ) =

log pgi(xi; θ),

(4.19)

i=1
X
X = xi; θ).

|

where pk(xi; θ) = Pr(G = k

We discuss in detail the two-class case, since the algorithms simplify
considerably. It is convenient to code the two-class gi via a 0/1 response yi,
where yi = 1 when gi = 1, and yi = 0 when gi = 2. Let p1(x; θ) = p(x; θ),
and p2(x; θ) = 1

p(x; θ). The log-likelihood can be written

−

N

ℓ(β) =

yi log p(xi; β) + (1

i=1n
X
N

=

yiβT xi −

yi) log(1

−

−

p(xi; β))

o

log(1 + eβT xi )

.

(4.20)

i=1 n
X
, and we assume that the vector of inputs xi includes

o

Here β =
the constant term 1 to accommodate the intercept.

β10, β1}
{

To maximize the log-likelihood, we set its derivatives to zero. These score

equations are

∂ℓ(β)
∂β

=

N

i=1
X

xi(yi −

p(xi; β)) = 0,

(4.21)

which are p + 1 equations nonlinear in β. Notice that since the ﬁrst compo-
N
nent of xi is 1, the ﬁrst score equation speciﬁes that
i=1 p(xi; β);
the expected number of class ones matches the observed number (and hence
also class twos.)

N
i=1 yi =

P

P

To solve the score equations (4.21), we use the Newton–Raphson algo-

rithm, which requires the second-derivative or Hessian matrix

∂2ℓ(β)
∂β∂βT =

−

N

i=1
X

xixi

T p(xi; β)(1

p(xi; β)).

−

(4.22)

Starting with βold, a single Newton update is

βnew = βold

∂2ℓ(β)
∂β∂βT

(cid:19)

−

(cid:18)

−1 ∂ℓ(β)
∂β

,

(4.23)

where the derivatives are evaluated at βold.

4.4 Logistic Regression

121

It is convenient to write the score and Hessian in matrix notation. Let
y denote the vector of yi values, X the N
(p + 1) matrix of xi values,
p the vector of ﬁtted probabilities with ith element p(xi; βold) and W a
N diagonal matrix of weights with ith diagonal element p(xi; βold)(1
N
p(xi; βold)). Then we have

×

−

×

∂ℓ(β)
∂β
∂2ℓ(β)
∂β∂βT =

= XT (y

p)

−

XT WX

−

The Newton step is thus

βnew = βold + (XT WX)−1XT (y
= (XT WX)−1XT W
= (XT WX)−1XT Wz.
(cid:0)

p)
Xβold + W−1(y

−

(4.24)

(4.25)

p)

−

(cid:1)

(4.26)

In the second and third line we have re-expressed the Newton step as a
weighted least squares step, with the response

z = Xβold + W−1(y

p),

−

(4.27)

sometimes known as the adjusted response. These equations get solved re-
peatedly, since at each iteration p changes, and hence so does W and z.
This algorithm is referred to as iteratively reweighted least squares or IRLS,
since each iteration solves the weighted least squares problem:

βnew

arg min

β

(z

−

←

Xβ)T W(z

Xβ).

−

(4.28)

It seems that β = 0 is a good starting value for the iterative procedure,
although convergence is never guaranteed. Typically the algorithm does
converge, since the log-likelihood is concave, but overshooting can occur.
In the rare cases that the log-likelihood decreases, step size halving will
guarantee convergence.

−

≥

For the multiclass case (K

3) the Newton algorithm can also be ex-
pressed as an iteratively reweighted least squares algorithm, but with a
vector of K
1 responses and a nondiagonal weight matrix per observation.
The latter precludes any simpliﬁed algorithms, and in this case it is numer-
ically more convenient to work with the expanded vector θ directly (Ex-
ercise 4.4). Alternatively coordinate-descent methods (Section 3.8.6) can
be used to maximize the log-likelihood eﬃciently. The R package glmnet
(Friedman et al., 2010) can ﬁt very large logistic regression problems ef-
ﬁciently, both in N and p. Although designed to ﬁt regularized models,
options allow for unregularized ﬁts.

Logistic regression models are used mostly as a data analysis and infer-
ence tool, where the goal is to understand the role of the input variables

122

4. Linear Methods for Classiﬁcation

TABLE 4.2. Results from a logistic regression ﬁt to the South African heart
disease data.

(Intercept)
sbp
tobacco
ldl
famhist
obesity
alcohol
age

−

Coeﬃcient
4.130
0.006
0.080
0.185
0.939
-0.035
0.001
0.043

−

Std. Error Z Score
4.285
1.023
3.034
3.219
4.178
1.187
0.136
4.184

0.964
0.006
0.026
0.057
0.225
0.029
0.004
0.010

−

in explaining the outcome. Typically many models are ﬁt in a search for a
parsimonious model involving a subset of the variables, possibly with some
interactions terms. The following example illustrates some of the issues
involved.

4.4.2 Example: South African Heart Disease

Here we present an analysis of binary data to illustrate the traditional
statistical use of the logistic regression model. The data in Figure 4.12 are a
subset of the Coronary Risk-Factor Study (CORIS) baseline survey, carried
out in three rural areas of the Western Cape, South Africa (Rousseauw et
al., 1983). The aim of the study was to establish the intensity of ischemic
heart disease risk factors in that high-incidence region. The data represent
white males between 15 and 64, and the response variable is the presence or
absence of myocardial infarction (MI) at the time of the survey (the overall
prevalence of MI was 5.1% in this region). There are 160 cases in our data
set, and a sample of 302 controls. These data are described in more detail
in Hastie and Tibshirani (1987).

We ﬁt a logistic-regression model by maximum likelihood, giving the
results shown in Table 4.2. This summary includes Z scores for each of the
coeﬃcients in the model (coeﬃcients divided by their standard errors); a
nonsigniﬁcant Z score suggests a coeﬃcient can be dropped from the model.
Each of these correspond formally to a test of the null hypothesis that the
coeﬃcient in question is zero, while all the others are not (also known as
the Wald test). A Z score greater than approximately 2 in absolute value
is signiﬁcant at the 5% level.

There are some surprises in this table of coeﬃcients, which must be in-
terpreted with caution. Systolic blood pressure (sbp) is not signiﬁcant! Nor
is obesity, and its sign is negative. This confusion is a result of the corre-
lation between the set of predictors. On their own, both sbp and obesity
are signiﬁcant, and with positive sign. However, in the presence of many

4.4 Logistic Regression

123

0

10

20

30

0.0

0.4

0.8

0

50 100

0
3

0
2

0
1

0

8

.

0

4

.

0

0
0

.

0
0
1

0
5

0

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
oo
o
o
oo
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
oo
o
o
o
o
o
o
o o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o oo
o
oo
oo
o
ooo
oooo
o
o
o
o
o
o
oo
o
oo
o oo
oo oo
oo
o
o
o
o oooooo
o
o
oo
oo
o
o
o
oooo
o
o
o
ooo
o
o
o
o
ooo
o
o
o
oo
oo
o
ooo
oo oo
o
o
o
o
oo
oo
o
oo
oo
o oo
o
o o
o o
o o
o
ooo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
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
ooo
o
o
o
oo
oo
o
o
o
oo
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o oo
o
o
o
oo
o
o
o
o
o
o
o
o
o o
o
oo o
o
oo
o
o
o
o
o o
o o
oo
o
oo
o
o
o oo
o
o
o
o
o
o
o
o
o
o
o
oo
o o
o
o
o o
o
o
o
oo
o oooooo
o
o
oo
ooo
o
o o
o
oo
oo
oo
o
o
o
o
oo
o
o
o oo
o o
o
o
o
o
o
o
o
o
o
o oo
oo
o o
o o
o
o
o
o
o
o
o oo
oo
o o
o
o
o
o
o
o
o
o o
o
oooo
o
o
o oo
o
o
o
oo
ooo
oooooooo
o
o
o
o
o
o o
o
o o
oo
o o
o
o
o
o
oo
oo
o
o
o
o ooo o
o
oo
o
o
o
o
o
o
o
o
o oo
o
o
oo
o
o
o o
o
o
o
o
oo
oo
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
ooo
o
o
o
o
ooo
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

age

20

40

60

0
2
2

0
6
1

0
0
1

4
1

0
1

6

2

5
4

5
3

5
2

5
1

0
6

0
4

0
2

FIGURE 4.12. A scatterplot matrix of the South African heart disease data.
Each plot shows a pair of risk factors, and the cases and controls are color coded
(red is a case). The variable family history of heart disease (famhist) is binary
(yes or no).

124

4. Linear Methods for Classiﬁcation

TABLE 4.3. Results from stepwise logistic regression ﬁt to South African heart
disease data.

(Intercept)
tobacco
ldl
famhist
age

−

Coeﬃcient
4.204
0.081
0.168
0.924
0.044

−

Std. Error Z score
8.45
3.16
3.09
4.14
4.52

0.498
0.026
0.054
0.223
0.010

other correlated variables, they are no longer needed (and can even get a
negative sign).

At this stage the analyst might do some model selection; ﬁnd a subset
of the variables that are suﬃcient for explaining their joint eﬀect on the
prevalence of chd. One way to proceed by is to drop the least signiﬁcant co-
eﬃcient, and reﬁt the model. This is done repeatedly until no further terms
can be dropped from the model. This gave the model shown in Table 4.3.
A better but more time-consuming strategy is to reﬁt each of the models
with one variable removed, and then perform an analysis of deviance to
decide which variable to exclude. The residual deviance of a ﬁtted model
is minus twice its log-likelihood, and the deviance between two models is
the diﬀerence of their individual residual deviances (in analogy to sums-of-
squares). This strategy gave the same ﬁnal model as above.

How does one interpret a coeﬃcient of 0.081 (Std. Error = 0.026) for
tobacco, for example? Tobacco is measured in total lifetime usage in kilo-
grams, with a median of 1.0kg for the controls and 4.1kg for the cases. Thus
an increase of 1kg in lifetime tobacco usage accounts for an increase in the
odds of coronary heart disease of exp(0.081) = 1.084 or 8.4%. Incorporat-
ing the standard error we get an approximate 95% conﬁdence interval of
exp(0.081

0.026) = (1.03, 1.14).

2

We return to these data in Chapter 5, where we see that some of the
variables have nonlinear eﬀects, and when modeled appropriately, are not
excluded from the model.

±

×

4.4.3 Quadratic Approximations and Inference
The maximum-likelihood parameter estimates ˆβ satisfy a self-consistency
relationship: they are the coeﬃcients of a weighted least squares ﬁt, where
the responses are

zi = xT
i

ˆβ +

(yi −
ˆpi(1
−

ˆpi)
ˆpi)

,

(4.29)

4.4 Logistic Regression

125

ˆpi), both depending on ˆβ itself. Apart from
and the weights are wi = ˆpi(1
providing a convenient algorithm, this connection with least squares has
more to oﬀer:

−

•

The weighted residual sum-of-squares is the familiar Pearson chi-
square statistic

N

i=1
X

(yi −
ˆpi(1
−

ˆpi)2
ˆpi)

,

(4.30)

a quadratic approximation to the deviance.

•

•

•

Asymptotic likelihood theory says that if the model is correct, then
ˆβ is consistent (i.e., converges to the true β).

A central limit theorem then shows that the distribution of ˆβ con-
verges to N (β, (XT WX)−1). This and other asymptotics can be de-
rived directly from the weighted least squares ﬁt by mimicking normal
theory inference.

Model building can be costly for logistic regression models, because
each model ﬁtted requires iteration. Popular shortcuts are the Rao
score test which tests for inclusion of a term, and the Wald test which
can be used to test for exclusion of a term. Neither of these require
iterative ﬁtting, and are based on the maximum-likelihood ﬁt of the
current model. It turns out that both of these amount to adding
or dropping a term from the weighted least squares ﬁt, using the
same weights. Such computations can be done eﬃciently, without
recomputing the entire weighted least squares ﬁt.

Software implementations can take advantage of these connections. For
example, the generalized linear modeling software in R (which includes lo-
gistic regression as part of the binomial family of models) exploits them
fully. GLM (generalized linear model) objects can be treated as linear model
objects, and all the tools available for linear models can be applied auto-
matically.

4.4.4 L1 Regularized Logistic Regression
The L1 penalty used in the lasso (Section 3.4.2) can be used for variable
selection and shrinkage with any linear regression model. For logistic re-
gression, we would maximize a penalized version of (4.20):

max
β0,β 


N

yi(β0 + βT xi)

i=1 h
X

log(1 + eβ0+βT xi )

−

p

λ

−

i

j=1
X

.

|

βj|


(4.31)

As with the lasso, we typically do not penalize the intercept term, and stan-
dardize the predictors for the penalty to be meaningful. Criterion (4.31) is





126

4. Linear Methods for Classiﬁcation

concave, and a solution can be found using nonlinear programming meth-
ods (Koh et al., 2007, for example). Alternatively, using the same quadratic
approximations that were used in the Newton algorithm in Section 4.4.1,
we can solve (4.31) by repeated application of a weighted lasso algorithm.
Interestingly, the score equations [see (4.24)] for the variables with non-zero
coeﬃcients have the form

xT
j (y

−

p) = λ

·

sign(βj),

(4.32)

which generalizes (3.58) in Section 3.4.4; the active variables are tied in
their generalized correlation with the residuals.

Path algorithms such as LAR for lasso are more diﬃcult, because the
coeﬃcient proﬁles are piecewise smooth rather than linear. Nevertheless,
progress can be made using quadratic approximations.

1

2

4

5

6

7

6
.
0

4
.
0

2
.
0

0
.
0

)
λ
(
j
β

s
t
n
e
i
c
ﬃ
e
o
C

*********************************************************************************************************************************************************************************************************************************************
*********************************************************************************************************************************************************************************************************************************************
*********************************************************************************************************************************************************************************************************************************************
*********************************************************************************************************************************************************************************************************************************************

*********************************************************************************************************************************************************************************************************************************************
*********************************************************************************************************************************************************************************************************************************************

*********************************************************************************************************************************************************************************************************************************************

age

famhist

ldl
tobacco

sbp

alcohol

obesity

0.0

0.5

1.0

1.5

2.0

β(λ)

1

||
FIGURE 4.13. L1 regularized logistic regression coeﬃcients for the South
African heart disease data, plotted as a function of the L1 norm. The variables
were all standardized to have unit variance. The proﬁles are computed exactly at
each of the plotted points.

||

Figure 4.13 shows the L1 regularization path for the South African
heart disease data of Section 4.4.2. This was produced using the R package
glmpath (Park and Hastie, 2007), which uses predictor–corrector methods
of convex optimization to identify the exact values of λ at which the active
set of non-zero coeﬃcients changes (vertical lines in the ﬁgure). Here the
proﬁles look almost linear; in other examples the curvature will be more
visible.

Coordinate descent methods (Section 3.8.6) are very eﬃcient for comput-
ing the coeﬃcient proﬁles on a grid of values for λ. The R package glmnet

4.4 Logistic Regression

127

(Friedman et al., 2010) can ﬁt coeﬃcient paths for very large logistic re-
gression problems eﬃciently (large in N or p). Their algorithms can exploit
sparsity in the predictor matrix X, which allows for even larger problems.
See Section 18.4 for more details, and a discussion of L1-regularized multi-
nomial models.

4.4.5 Logistic Regression or LDA?

In Section 4.3 we ﬁnd that the log-posterior odds between class k and K
are linear functions of x (4.9):

log

Pr(G = k
|
Pr(G = K
|

X = x)
X = x)

(µk + µK)T Σ−1(µk −

= log

πk
1
πK −
2
+xT Σ−1(µk −
k x.

= αk0 + αT

µK )

µK)

(4.33)

This linearity is a consequence of the Gaussian assumption for the class
densities, as well as the assumption of a common covariance matrix. The
linear logistic model (4.17) by construction has linear logits:

log

Pr(G = k
|
Pr(G = K
|

X = x)
X = x)

= βk0 + βT

k x.

(4.34)

It seems that the models are the same. Although they have exactly the same
form, the diﬀerence lies in the way the linear coeﬃcients are estimated. The
logistic regression model is more general, in that it makes less assumptions.
We can write the joint density of X and G as

Pr(X, G = k) = Pr(X)Pr(G = k

X),

|

(4.35)

where Pr(X) denotes the marginal density of the inputs X. For both LDA
and logistic regression, the second term on the right has the logit-linear
form

Pr(G = k

|

X = x) =

1 +

eβk0+βT
k x
K−1
ℓ=1 eβℓ0+βT
ℓ x

,

(4.36)

P

where we have again arbitrarily chosen the last class as the reference.

The logistic regression model leaves the marginal density of X as an arbi-
trary density function Pr(X), and ﬁts the parameters of Pr(G
X) by max-
|
imizing the conditional likelihood—the multinomial likelihood with proba-
bilities the Pr(G = k
X). Although Pr(X) is totally ignored, we can think
of this marginal density as being estimated in a fully nonparametric and
unrestricted fashion, using the empirical distribution function which places
mass 1/N at each observation.

|

With LDA we ﬁt the parameters by maximizing the full log-likelihood,

based on the joint density

Pr(X, G = k) = φ(X; µk, Σ)πk,

(4.37)

128

4. Linear Methods for Classiﬁcation

where φ is the Gaussian density function. Standard normal theory leads
easily to the estimates ˆµk, ˆΣ, and ˆπk given in Section 4.3. Since the linear
parameters of the logistic form (4.33) are functions of the Gaussian param-
eters, we get their maximum-likelihood estimates by plugging in the corre-
sponding estimates. However, unlike in the conditional case, the marginal
density Pr(X) does play a role here. It is a mixture density

K

Pr(X) =

πkφ(X; µk, Σ),

(4.38)

Xk=1

which also involves the parameters.

What role can this additional component/restriction play? By relying
on the additional model assumptions, we have more information about the
parameters, and hence can estimate them more eﬃciently (lower variance).
If in fact the true fk(x) are Gaussian, then in the worst case ignoring this
marginal part of the likelihood constitutes a loss of eﬃciency of about 30%
asymptotically in the error rate (Efron, 1975). Paraphrasing: with 30%
more data, the conditional likelihood will do as well.

For example, observations far from the decision boundary (which are
down-weighted by logistic regression) play a role in estimating the common
covariance matrix. This is not all good news, because it also means that
LDA is not robust to gross outliers.

From the mixture formulation, it is clear that even observations without
class labels have information about the parameters. Often it is expensive
to generate class labels, but unclassiﬁed observations come cheaply. By
relying on strong model assumptions, such as here, we can use both types
of information.

The marginal likelihood can be thought of as a regularizer, requiring
in some sense that class densities be visible from this marginal view. For
example, if the data in a two-class logistic regression model can be per-
fectly separated by a hyperplane, the maximum likelihood estimates of the
parameters are undeﬁned (i.e., inﬁnite; see Exercise 4.5). The LDA coeﬃ-
cients for the same data will be well deﬁned, since the marginal likelihood
will not permit these degeneracies.

In practice these assumptions are never correct, and often some of the
components of X are qualitative variables. It is generally felt that logistic
regression is a safer, more robust bet than the LDA model, relying on fewer
assumptions. It is our experience that the models give very similar results,
even when LDA is used inappropriately, such as with qualitative predictors.

4.5 Separating Hyperplanes

129

FIGURE 4.14. A toy example with two classes separable by a hyperplane. The
orange line is the least squares solution, which misclassiﬁes one of the training
points. Also shown are two blue separating hyperplanes found by the perceptron
learning algorithm with diﬀerent random starts.

4.5 Separating Hyperplanes

We have seen that linear discriminant analysis and logistic regression both
estimate linear decision boundaries in similar but slightly diﬀerent ways.
For the rest of this chapter we describe separating hyperplane classiﬁers.
These procedures construct linear decision boundaries that explicitly try
to separate the data into diﬀerent classes as well as possible. They provide
the basis for support vector classiﬁers, discussed in Chapter 12. The math-
ematical level of this section is somewhat higher than that of the previous
sections.

Figure 4.14 shows 20 data points in two classes in IR2. These data can be
separated by a linear boundary. Included in the ﬁgure (blue lines) are two
of the inﬁnitely many possible separating hyperplanes. The orange line is
the least squares solution to the problem, obtained by regressing the
1/1
response Y on X (with intercept); the line is given by

−

x : ˆβ0 + ˆβ1x1 + ˆβ2x2 = 0
.
}
{

(4.39)

This least squares solution does not do a perfect job in separating the
points, and makes one error. This is the same boundary found by LDA,
in light of its equivalence with linear regression in the two-class case (Sec-
tion 4.3 and Exercise 4.2).

Classiﬁers such as (4.39), that compute a linear combination of the input
features and return the sign, were called perceptrons in the engineering liter-

130

4. Linear Methods for Classiﬁcation

x0

x

β0 + βT x = 0

β∗

FIGURE 4.15. The linear algebra of a hyperplane (aﬃne set).

ature in the late 1950s (Rosenblatt, 1958). Perceptrons set the foundations
for the neural network models of the 1980s and 1990s.

Before we continue, let us digress slightly and review some vector algebra.
Figure 4.15 depicts a hyperplane or aﬃne set L deﬁned by the equation
f (x) = β0 + βT x = 0; since we are in IR2 this is a line.

Here we list some properties:
1. For any two points x1 and x2 lying in L, βT (x1 −

is the vector normal to the surface of L.

β

β∗ = β/
||

||

x2) = 0, and hence

2. For any point x0 in L, βT x0 =

β0.

−

3. The signed distance of any point x to L is given by

β∗T (x

x0) =

−

(βT x + β0)

1
β
k

k
1
f ′(x)

=

||

f (x).

||

(4.40)

Hence f (x) is proportional to the signed distance from x to the hyperplane
deﬁned by f (x) = 0.

4.5.1 Rosenblatt’s Perceptron Learning Algorithm

The perceptron learning algorithm tries to ﬁnd a separating hyperplane by
minimizing the distance of misclassiﬁed points to the decision boundary. If

4.5 Separating Hyperplanes

131

a response yi = 1 is misclassiﬁed, then xT
a misclassiﬁed response with yi =

i β + β0 < 0, and the opposite for

1. The goal is to minimize

−

D(β, β0) =

−

Xi∈M

yi(xT

i β + β0),

(4.41)

M

where
indexes the set of misclassiﬁed points. The quantity is non-
negative and proportional to the distance of the misclassiﬁed points to
the decision boundary deﬁned by βT x + β0 = 0. The gradient (assuming

is ﬁxed) is given by

M

∂

D(β, β0)
∂β

∂

D(β, β0)
∂β0

=

=

yixi,

yi.

−

−

Xi∈M

Xi∈M

(4.42)

(4.43)

The algorithm in fact uses stochastic gradient descent to minimize this
piecewise linear criterion. This means that rather than computing the sum
of the gradient contributions of each observation followed by a step in the
negative gradient direction, a step is taken after each observation is visited.
Hence the misclassiﬁed observations are visited in some sequence, and the
parameters β are updated via

←

+ ρ

β
β0(cid:19)
(cid:18)

β
β0(cid:19)
Here ρ is the learning rate, which in this case can be taken to be 1 without
loss in generality. If the classes are linearly separable, it can be shown that
the algorithm converges to a separating hyperplane in a ﬁnite number of
steps (Exercise 4.6). Figure 4.14 shows two solutions to a toy problem, each
started at a diﬀerent random guess.

yixi
yi (cid:19)

(4.44)

(cid:18)

(cid:18)

.

There are a number of problems with this algorithm, summarized in

Ripley (1996):

•

•

•

When the data are separable, there are many solutions, and which
one is found depends on the starting values.

The “ﬁnite” number of steps can be very large. The smaller the gap,
the longer the time to ﬁnd it.

When the data are not separable, the algorithm will not converge,
and cycles develop. The cycles can be long and therefore hard to
detect.

The second problem can often be eliminated by seeking a hyperplane not
in the original space, but in a much enlarged space obtained by creating

132

4. Linear Methods for Classiﬁcation

many basis-function transformations of the original variables. This is anal-
ogous to driving the residuals in a polynomial regression problem down
to zero by making the degree suﬃciently large. Perfect separation cannot
always be achieved: for example, if observations from two diﬀerent classes
share the same input. It may not be desirable either, since the resulting
model is likely to be overﬁt and will not generalize well. We return to this
point at the end of the next section.

A rather elegant solution to the ﬁrst problem is to add additional con-

straints to the separating hyperplane.

4.5.2 Optimal Separating Hyperplanes

The optimal separating hyperplane separates the two classes and maximizes
the distance to the closest point from either class (Vapnik, 1996). Not only
does this provide a unique solution to the separating hyperplane problem,
but by maximizing the margin between the two classes on the training data,
this leads to better classiﬁcation performance on test data.

We need to generalize criterion (4.41). Consider the optimization problem

max
β,β0,||β||=1

M

subject to yi(xT

i β + β0)

M, i = 1, . . . , N.

≥

(4.45)

The set of conditions ensure that all the points are at least a signed
distance M from the decision boundary deﬁned by β and β0, and we seek
the largest such M and associated parameters. We can get rid of the
=
1 constraint by replacing the conditions with

β

||

||

1
β

||

||

yi(xT

i β + β0)

M,

≥

(which redeﬁnes β0) or equivalently

yi(xT

i β + β0)

M

β

.

||

||

≥

(4.46)

(4.47)

Since for any β and β0 satisfying these inequalities, any positively scaled
multiple satisﬁes them too, we can arbitrarily set
= 1/M . Thus (4.45)
is equivalent to

β

||

||

min
β,β0
subject to yi(xT

2

β

1
2 ||
||
i β + β0)

1, i = 1, . . . , N.

≥

(4.48)

In light of (4.40), the constraints deﬁne an empty slab or margin around the
. Hence we choose β and β0 to
linear decision boundary of thickness 1/
maximize its thickness. This is a convex optimization problem (quadratic

β

||

||

4.5 Separating Hyperplanes

133

criterion with linear inequality constraints). The Lagrange (primal) func-
tion, to be minimized w.r.t. β and β0, is

LP =

1
2 ||

β

2

||

−

N

i=1
X

αi[yi(xT

i β + β0)

1].

−

(4.49)

Setting the derivatives to zero, we obtain:

N

β =

αiyixi,

0 =

i=1
X
N

i=1
X

αiyi,

(4.50)

(4.51)

and substituting these in (4.49) we obtain the so-called Wolfe dual

N

LD =

αi −

1
2

N

N

αiαkyiykxT

i xk

Xk=1

i=1
i=1
X
X
subject to αi ≥

N

0 and

αiyi = 0.

(4.52)

i=1
X

The solution is obtained by maximizing LD in the positive orthant, a sim-
pler convex optimization problem, for which standard software can be used.
In addition the solution must satisfy the Karush–Kuhn–Tucker conditions,
which include (4.50), (4.51), (4.52) and

αi[yi(xT

i β + β0)

1] = 0

i.

∀

−

(4.53)

From these we can see that

if αi > 0, then yi(xT
boundary of the slab;

i β + β0) = 1, or in other words, xi is on the

if yi(xT

i β + β0) > 1, xi is not on the boundary of the slab, and αi = 0.

•

•

From (4.50) we see that the solution vector β is deﬁned in terms of a linear
combination of the support points xi—those points deﬁned to be on the
boundary of the slab via αi > 0. Figure 4.16 shows the optimal separating
hyperplane for our toy example; there are three support points. Likewise,
β0 is obtained by solving (4.53) for any of the support points.

The optimal separating hyperplane produces a function ˆf (x) = xT ˆβ + ˆβ0

for classifying new observations:

ˆG(x) = sign ˆf (x).

(4.54)

Although none of the training observations fall in the margin (by con-
struction), this will not necessarily be the case for test observations. The

134

4. Linear Methods for Classiﬁcation

FIGURE 4.16. The same data as in Figure 4.14. The shaded region delineates
the maximum margin separating the two classes. There are three support points
indicated, which lie on the boundary of the margin, and the optimal separating
hyperplane (blue line) bisects the slab. Included in the ﬁgure is the boundary found
using logistic regression (red line), which is very close to the optimal separating
hyperplane (see Section 12.3.3).

intuition is that a large margin on the training data will lead to good
separation on the test data.

The description of the solution in terms of support points seems to sug-
gest that the optimal hyperplane focuses more on the points that count,
and is more robust to model misspeciﬁcation. The LDA solution, on the
other hand, depends on all of the data, even points far away from the de-
cision boundary. Note, however, that the identiﬁcation of these support
points required the use of all the data. Of course, if the classes are really
Gaussian, then LDA is optimal, and separating hyperplanes will pay a price
for focusing on the (noisier) data at the boundaries of the classes.

Included in Figure 4.16 is the logistic regression solution to this prob-
lem, ﬁt by maximum likelihood. Both solutions are similar in this case.
When a separating hyperplane exists, logistic regression will always ﬁnd
it, since the log-likelihood can be driven to 0 in this case (Exercise 4.5).
The logistic regression solution shares some other qualitative features with
the separating hyperplane solution. The coeﬃcient vector is deﬁned by a
weighted least squares ﬁt of a zero-mean linearized response on the input
features, and the weights are larger for points near the decision boundary
than for those further away.

When the data are not separable, there will be no feasible solution to
this problem, and an alternative formulation is needed. Again one can en-
large the space using basis transformations, but this can lead to artiﬁcial

separation through over-ﬁtting. In Chapter 12 we discuss a more attractive
alternative known as the support vector machine, which allows for overlap,
but minimizes a measure of the extent of this overlap.

Exercises

135

Bibliographic Notes

Good general texts on classiﬁcation include Duda et al. (2000), Hand
(1981), McLachlan (1992) and Ripley (1996). Mardia et al. (1979) have
a concise discussion of linear discriminant analysis. Michie et al. (1994)
compare a large number of popular classiﬁers on benchmark datasets. Lin-
ear separating hyperplanes are discussed in Vapnik (1996). Our account of
the perceptron learning algorithm follows Ripley (1996).

Exercises

Ex. 4.1 Show how to solve the generalized eigenvalue problem max aT Ba
subject to aT Wa = 1 by transforming to a standard eigenvalue problem.

Ex. 4.2 Suppose we have features x
∈
sizes N1, N2, and the target coded as

IRp, a two-class response, with class

N/N1, N/N2.

−

(a) Show that the LDA rule classiﬁes to class 2 if

−1

xT ˆΣ

ˆµ1) >

(ˆµ2 −
and class 1 otherwise.

1
2

(ˆµ2 + ˆµ1)T ˆΣ

−1

(ˆµ2 −

ˆµ1)

−

log(N2/N1),

(b) Consider minimization of the least squares criterion

N

i=1
X

(yi −

β0 −

i β)2.
xT

(4.55)

Show that the solution ˆβ satisﬁes

(N

2) ˆΣ + N ˆΣB

β = N (ˆµ2 −
−
(after simpliﬁcation), where ˆΣB = N1N2
N 2 (ˆµ2 −
(c) Hence show that ˆΣBβ is in the direction (ˆµ2 −

i

h

ˆµ1)

(4.56)

ˆµ1)T .

ˆµ1)(ˆµ2 −
ˆµ1) and thus

−1

ˆΣ

ˆβ

∝

(ˆµ2 −

ˆµ1).

(4.57)

Therefore the least-squares regression coeﬃcient is identical to the
LDA coeﬃcient, up to a scalar multiple.

136

4. Linear Methods for Classiﬁcation

(d) Show that this result holds for any (distinct) coding of the two classes.

(e) Find the solution ˆβ0 (up to the same scalar multiple as in (c), and
hence the predicted value ˆf (x) = ˆβ0 + xT ˆβ. Consider the following
rule: classify to class 2 if ˆf (x) > 0 and class 1 otherwise. Show this is
not the same as the LDA rule unless the classes have equal numbers
of observations.

(Fisher, 1936; Ripley, 1996)

Ex. 4.3 Suppose we transform the original predictors X to ˆY via linear
regression. In detail, let ˆY = X(XT X)−1XT Y = X ˆB, where Y is the
IRp, we get a trans-
indicator response matrix. Similarly for any input x
formed vector ˆy = ˆBT x
IRK . Show that LDA using ˆY is identical to
∈
LDA in the original space.

∈

−

Ex. 4.4 Consider the multilogit model with K classes (4.17). Let β be the
(p + 1)(K
1)-vector consisting of all the coeﬃcients. Deﬁne a suitably
enlarged version of the input vector x to accommodate this vectorized co-
eﬃcient matrix. Derive the Newton-Raphson algorithm for maximizing the
multinomial log-likelihood, and describe how you would implement this
algorithm.

IR. Char-
Ex. 4.5 Consider a two-class logistic regression problem with x
acterize the maximum-likelihood estimates of the slope and intercept pa-
IR.
rameter if the sample xi for the two classes are separated by a point x0 ∈
IRp (see Figure 4.16), and (b) more than
Generalize this result to (a) x
two classes.

∈

∈

Ex. 4.6 Suppose we have N points xi in IRp in general position, with class
. Prove that the perceptron learning algorithm converges
1, 1
labels yi ∈ {−
}
to a separating hyperplane in a ﬁnite number of steps:

(a) Denote a hyperplane by f (x) = βT

1 x + β0 = 0, or in more compact
notation βT x∗ = 0, where x∗ = (x, 1) and β = (β1, β0). Let zi =
x∗
x∗
. Show that separability implies the existence of a βsep such
i /
i ||
||
that yiβT
sepzi ≥

∀

1

i

(b) Given a current βold, the perceptron algorithm identiﬁes a point zi that
βold + yizi. Show
1, and hence that the algorithm
2
βsep||

is misclassiﬁed, and produces the update βnew ←
that
βold −
βnew −
converges to a separating hyperplane in no more than
steps (Ripley, 1996).

βstart −

βsep||

βsep||

≤ ||

−

||

||

2

2

Ex. 4.7 Consider the criterion

D∗(β, β0) =

N

−

i=1
X

yi(xT

i β + β0),

(4.58)

Exercises

137

a generalization of (4.41) where we sum over all the observations. Consider
minimizing D∗ subject to
= 1. Describe this criterion in words. Does
||
it solve the optimal separating hyperplane problem?

β

||

N (µk, Σ),
Ex. 4.8 Consider the multivariate Gaussian model X
1, p).
with the additional restriction that rank
Derive the constrained MLEs for the µk and Σ. Show that the Bayes clas-
siﬁcation rule is equivalent to classifying in the reduced subspace computed
by LDA (Hastie and Tibshirani, 1996b).

G = k
K
1 = L < max(K

µk}
{

∼

−

|

Ex. 4.9 Write a computer program to perform a quadratic discriminant
analysis by ﬁtting a separate Gaussian model per class. Try it out on the
vowel data, and compute the misclassiﬁcation error for the test data. The
data can be found in the book website www-stat.stanford.edu/ElemStatLearn.

138

4. Linear Methods for Classiﬁcation

5
Basis Expansions and Regularization

This is page 139
Printer: Opaque this

5.1

Introduction

We have already made use of models linear in the input features, both for
regression and classiﬁcation. Linear regression, linear discriminant analysis,
logistic regression and separating hyperplanes all rely on a linear model.
It is extremely unlikely that the true function f (X) is actually linear in
X) will typically be nonlinear and
X. In regression problems, f (X) = E(Y
nonadditive in X, and representing f (X) by a linear model is usually a con-
venient, and sometimes a necessary, approximation. Convenient because a
linear model is easy to interpret, and is the ﬁrst-order Taylor approxima-
tion to f (X). Sometimes necessary, because with N small and/or p large,
a linear model might be all we are able to ﬁt to the data without overﬁt-
ting. Likewise in classiﬁcation, a linear, Bayes-optimal decision boundary
implies that some monotone transformation of Pr(Y = 1
X) is linear in X.
|
This is inevitably an approximation.

|

In this chapter and the next we discuss popular methods for moving
beyond linearity. The core idea in this chapter is to augment/replace the
vector of inputs X with additional variables, which are transformations of
X, and then use linear models in this new space of derived input features.
IR the mth transformation of X, m =

Denote by hm(X) : IRp

1, . . . , M . We then model

7→

M

f (X) =

βmhm(X),

m=1
X

(5.1)

140

5. Basis Expansions and Regularization

a linear basis expansion in X. The beauty of this approach is that once the
basis functions hm have been determined, the models are linear in these
new variables, and the ﬁtting proceeds as before.

Some simple and widely used examples of the hm are the following:

•

•

•

•

hm(X) = Xm, m = 1, . . . , p recovers the original linear model.

hm(X) = X 2
j or hm(X) = XjXk allows us to augment the inputs with
polynomial terms to achieve higher-order Taylor expansions. Note,
however, that the number of variables grows exponentially in the de-
gree of the polynomial. A full quadratic model in p variables requires
O(p2) square and cross-product terms, or more generally O(pd) for a
degree-d polynomial.

Xj, . . . permits other nonlinear transformations
hm(X) = log(Xj),
of single inputs. More generally one can use similar functions involv-
ing several inputs, such as hm(X) =

p

X

.

||

||

Xk < Um), an indicator for a region of Xk. By
hm(X) = I(Lm ≤
breaking the range of Xk up into Mk such nonoverlapping regions
results in a model with a piecewise constant contribution for Xk.

Sometimes the problem at hand will call for particular basis functions hm,
such as logarithms or power functions. More often, however, we use the basis
expansions as a device to achieve more ﬂexible representations for f (X).
Polynomials are an example of the latter, although they are limited by
their global nature—tweaking the coeﬃcients to achieve a functional form
in one region can cause the function to ﬂap about madly in remote regions.
In this chapter we consider more useful families of piecewise-polynomials
and splines that allow for local polynomial representations. We also discuss
the wavelet bases, especially useful for modeling signals and images. These
consisting of typically a very large number
methods produce a dictionary
of basis functions, far more than we can aﬀord to ﬁt to our data. Along
|D|
with the dictionary we require a method for controlling the complexity
of our model, using basis functions from the dictionary. There are three
common approaches:

D

•

Restriction methods, where we decide before-hand to limit the class
of functions. Additivity is an example, where we assume that our
model has the form

p

f (X) =

fj(Xj)

j=1
X
p

Mj

=

βjmhjm(Xj).

(5.2)

j=1
X

m=1
X

5.2 Piecewise Polynomials and Splines

141

•

•

The size of the model is limited by the number of basis functions Mj
used for each component function fj.

Selection methods, which adaptively scan the dictionary and include
only those basis functions hm that contribute signiﬁcantly to the ﬁt of
the model. Here the variable selection techniques discussed in Chap-
ter 3 are useful. The stagewise greedy approaches such as CART,
MARS and boosting fall into this category as well.

Regularization methods where we use the entire dictionary but re-
strict the coeﬃcients. Ridge regression is a simple example of a regu-
larization approach, while the lasso is both a regularization and selec-
tion method. Here we discuss these and more sophisticated methods
for regularization.

5.2 Piecewise Polynomials and Splines

We assume until Section 5.7 that X is one-dimensional. A piecewise poly-
nomial function f (X) is obtained by dividing the domain of X into contigu-
ous intervals, and representing f by a separate polynomial in each interval.
Figure 5.1 shows two simple piecewise polynomials. The ﬁrst is piecewise
constant, with three basis functions:

h1(X) = I(X < ξ1),

h2(X) = I(ξ1 ≤

X < ξ2),

h3(X) = I(ξ2 ≤

X).

P

Since these are positive over disjoint regions, the least squares estimate of
m=1 βmhm(X) amounts to ˆβm = ¯Ym, the mean of Y
the model f (X) =
in the mth region.

3

The top right panel shows a piecewise linear ﬁt. Three additional basis
functions are needed: hm+3 = hm(X)X, m = 1, . . . , 3. Except in special
cases, we would typically prefer the third panel, which is also piecewise
linear, but restricted to be continuous at the two knots. These continu-
ity restrictions lead to linear constraints on the parameters; for example,
f (ξ−
1 ) implies that β1 + ξ1β4 = β2 + ξ1β5. In this case, since there
are two restrictions, we expect to get back two parameters, leaving four free
parameters.

1 ) = f (ξ+

A more direct way to proceed in this case is to use a basis that incorpo-

rates the constraints:

h1(X) = 1,

h2(X) = X,

h3(X) = (X

ξ1)+,

h4(X) = (X

ξ2)+,

−

−

where t+ denotes the positive part. The function h3 is shown in the lower
right panel of Figure 5.1. We often prefer smoother functions, and these
can be achieved by increasing the order of the local polynomial. Figure 5.2
shows a series of piecewise-cubic polynomials ﬁt to the same data, with

142

5. Basis Expansions and Regularization

Piecewise Constant

Piecewise Linear

O
O

O

O

O
O
O
O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O
O

O
O

O

O

O

O

O

O
O

O

O
O

O
O

O

O

O

O
O
O

O

O

O
O

O

O

O
O
O
O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O
O

O
O

O

O

O

O

O

O
O

O

O
O

O
O

O

O

O

O
O
O

O

O

O

O

ξ1

ξ2

ξ1

ξ2

Continuous Piecewise Linear

Piecewise-linear Basis Function

O
O

O

O
O

O
O

O

O

O

O
O
O

O

O

O
O

O

O

O
O
O
O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O

O
O

O
O

O

O

O

O

O

O

•
•
•

•
•
•
••
•
•
•

(X

−

ξ1)+

•
•

•

•

•

•
•
•

•
•

•
•
•

•

•

••
•
•

•
•
•
•
•
••
•

•
•

•
•

•
•

•

•
•
•

•
•

ξ1

ξ2

ξ1

ξ2

FIGURE 5.1. The top left panel shows a piecewise constant function ﬁt to some
artiﬁcial data. The broken vertical lines indicate the positions of the two knots
ξ1 and ξ2. The blue curve represents the true function, from which the data were
generated with Gaussian noise. The remaining two panels show piecewise lin-
ear functions ﬁt to the same data—the top right unrestricted, and the lower left
restricted to be continuous at the knots. The lower right panel shows a piecewise–
linear basis function, h3(X) = (X
ξ1)+, continuous at ξ1. The black points
indicate the sample evaluations h3(xi), i = 1, . . . , N .

−

5.2 Piecewise Polynomials and Splines

143

Piecewise Cubic Polynomials

Discontinuous

Continuous

O

O
O

O

O

O
O
O
O

O

O

O

O

O

O

O

O

O

O

O

O

O

O
O

O
O

O
O

O
O
O

O

O

O

O

O

O

O

O

O

O
O
O

O

O

O

O
O

O

O

O
O

O

O

O
O
O
O

O

O

O

O

O

O

O

O

O

O

O

O

O

O
O

O
O

O
O

O
O
O

O

O

O

O

O

O

O

O

O

O
O
O

O

O

O

O

O

ξ1

ξ2

ξ1

ξ2

Continuous First Derivative

Continuous Second Derivative

O
O

O

O

O
O
O
O

O

O

O

O

O

O

O

O

O

O

O

O

O
O

O
O
O

O

O

O
O

O
O

O

O

O

O

O

O

O

O

O

O
O
O

O

O

O

O
O

O

O
O

O

O

O
O
O
O

O

O

O

O

O

O

O

O

O

O

O

O

O
O

O
O
O

O

O

O
O

O
O

O

O

O

O

O

O

O

O

O

O
O
O

O

O

O

O
O

O

O
O

O

O

O

ξ1

ξ2

ξ1

ξ2

FIGURE 5.2. A series of piecewise-cubic polynomials, with increasing orders of
continuity.

increasing orders of continuity at the knots. The function in the lower
right panel is continuous, and has continuous ﬁrst and second derivatives
at the knots. It is known as a cubic spline. Enforcing one more order of
continuity would lead to a global cubic polynomial. It is not hard to show
(Exercise 5.1) that the following basis represents a cubic spline with knots
at ξ1 and ξ2:

h3(X) = X 2, h5(X) = (X
h1(X) = 1,
h2(X) = X, h4(X) = X 3, h6(X) = (X

ξ1)3
+,
ξ2)3
+.

−

−

(5.3)

There are six basis functions corresponding to a six-dimensional linear space
(4
of functions. A quick check conﬁrms the parameter count: (3 regions)
parameters per region)

(3 constraints per knot)= 6.

(2 knots)

×

−

×

144

5. Basis Expansions and Regularization

More generally, an order-M spline with knots ξj, j = 1, . . . , K is a
piecewise-polynomial of order M , and has continuous derivatives up to
order M
2. A cubic spline has M = 4. In fact the piecewise-constant
function in Figure 5.1 is an order-1 spline, while the continuous piece-
wise linear function is an order-2 spline. Likewise the general form for the
truncated-power basis set would be

−

hj(X) = X j−1, j = 1, . . . , M,

hM +ℓ(X) = (X

−

ξℓ)M −1
+

, ℓ = 1, . . . , K.

It is claimed that cubic splines are the lowest-order spline for which the
knot-discontinuity is not visible to the human eye. There is seldom any
good reason to go beyond cubic-splines, unless one is interested in smooth
derivatives. In practice the most widely used orders are M = 1, 2 and 4.

These ﬁxed-knot splines are also known as regression splines. One needs
to select the order of the spline, the number of knots and their placement.
One simple approach is to parameterize a family of splines by the number
of basis functions or degrees of freedom, and have the observations xi de-
termine the positions of the knots. For example, the expression bs(x,df=7)
in R generates a basis matrix of cubic-spline functions evaluated at the N
3 = 41 interior knots at the appropriate per-
observations in x, with the 7
centiles of x (20, 40, 60 and 80th.) One can be more explicit, however; bs(x,
degree=1, knots = c(0.2, 0.4, 0.6)) generates a basis for linear splines,
with three interior knots, and returns an N

4 matrix.

−

Since the space of spline functions of a particular order and knot sequence
is a vector space, there are many equivalent bases for representing them
(just as there are for ordinary polynomials.) While the truncated power
basis is conceptually simple, it is not too attractive numerically: powers of
large numbers can lead to severe rounding problems. The B-spline basis,
described in the Appendix to this chapter, allows for eﬃcient computations
even when the number of knots K is large.

×

5.2.1 Natural Cubic Splines

We know that the behavior of polynomials ﬁt to data tends to be erratic
near the boundaries, and extrapolation can be dangerous. These problems
are exacerbated with splines. The polynomials ﬁt beyond the boundary
knots behave even more wildly than the corresponding global polynomials
in that region. This can be conveniently summarized in terms of the point-
wise variance of spline functions ﬁt by least squares (see the example in the
next section for details on these variance calculations). Figure 5.3 compares

1A cubic spline with four knots is eight-dimensional. The bs() function omits by
default the constant term in the basis, since terms like this are typically included with
other terms in the model.

5.2 Piecewise Polynomials and Splines

145

Global Linear
Global Cubic Polynomial
Cubic Spline - 2 knots
Natural Cubic Spline - 6 knots

••
••
••

• ••
•
•
••
••
•• • ••

•••••
•••••
••
••
••••• ••
••••• ••

•• •• • ••
••••••
•••••• •• •• • ••
•••••• •• •• • ••
•••••• •• •• • ••

•

••••
•••• • •• •• • • ••• ••
•• •• • • •••
••
•••• • •• •• • • ••• ••
•••• • •• •• • • ••• ••

•

•
•

••
••
••

••
••
••
••
••
••
•• •••• •

•

•
•

•

6
.
0

5
.
0

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

s
e
c
n
a
i
r
a
V
e
s
w
t
n
o
P

i

i

0.0

0.2

0.4

0.6

0.8

1.0

X

FIGURE 5.3. Pointwise variance curves for four diﬀerent models, with X con-
sisting of 50 points drawn at random from U [0, 1], and an assumed error model
with constant variance. The linear and cubic polynomial ﬁts have two and four
degrees of freedom, respectively, while the cubic spline and natural cubic spline
each have six degrees of freedom. The cubic spline has two knots at 0.33 and 0.66,
while the natural spline has boundary knots at 0.1 and 0.9, and four interior knots
uniformly spaced between them.

the pointwise variances for a variety of diﬀerent models. The explosion of
the variance near the boundaries is clear, and inevitably is worst for cubic
splines.

A natural cubic spline adds additional constraints, namely that the func-
tion is linear beyond the boundary knots. This frees up four degrees of
freedom (two constraints each in both boundary regions), which can be
spent more proﬁtably by sprinkling more knots in the interior region. This
tradeoﬀ is illustrated in terms of variance in Figure 5.3. There will be a
price paid in bias near the boundaries, but assuming the function is lin-
ear near the boundaries (where we have less information anyway) is often
considered reasonable.

A natural cubic spline with K knots is represented by K basis functions.
One can start from a basis for cubic splines, and derive the reduced ba-
sis by imposing the boundary constraints. For example, starting from the
truncated power series basis described in Section 5.2, we arrive at (Exer-
cise 5.4):

N1(X) = 1, N2(X) = X, Nk+2(X) = dk(X)

dK−1(X),

(5.4)

−

 
146

5. Basis Expansions and Regularization

where

dk(X) =

(X

−

ξk)3

(X
ξk

+ −
ξK −

ξK )3
+

.

−

(5.5)

Each of these basis functions can be seen to have zero second and third
derivative for X

ξK .

≥

5.2.2 Example: South African Heart Disease (Continued)

In Section 4.4.2 we ﬁt linear logistic regression models to the South African
heart disease data. Here we explore nonlinearities in the functions using
natural splines. The functional form of the model is

logit[Pr(chd

|

X)] = θ0 + h1(X1)T θ1 + h2(X2)T θ2 +

+ hp(Xp)T θp, (5.6)

· · ·

where each of the θj are vectors of coeﬃcients multiplying their associated
vector of natural spline basis functions hj.

We use four natural spline bases for each term in the model. For example,
with X1 representing sbp, h1(X1) is a basis consisting of four basis func-
tions. This actually implies three rather than two interior knots (chosen at
uniform quantiles of sbp), plus two boundary knots at the extremes of the
data, since we exclude the constant term from each of the hj.

Since famhist is a two-level factor, it is coded by a simple binary or
dummy variable, and is associated with a single coeﬃcient in the ﬁt of the
model.

More compactly we can combine all p vectors of basis functions (and
the constant term) into one big vector h(X), and then the model is simply
p
h(X)T θ, with total number of parameters df = 1 +
j=1 dfj, the sum of
the parameters in each component term. Each basis function is evaluated
df basis matrix H. At this
at each of the N samples, resulting in a N
point the model is like any other linear logistic model, and the algorithms
described in Section 4.4.1 apply.

P

×

We carried out a backward stepwise deletion process, dropping terms
from this model while preserving the group structure of each term, rather
than dropping one coeﬃcient at a time. The AIC statistic (Section 7.5) was
used to drop terms, and all the terms remaining in the ﬁnal model would
cause AIC to increase if deleted from the model (see Table 5.1). Figure 5.4
shows a plot of the ﬁnal model selected by the stepwise regression. The
functions displayed are ˆfj(Xj) = hj(Xj)T ˆθj for each variable Xj. The
covariance matrix Cov(ˆθ) = Σ is estimated by ˆΣ = (HT WH)−1, where W
is the diagonal weight matrix from the logistic regression. Hence vj(Xj) =
Var[ ˆfj(Xj)] = hj(Xj)T ˆΣjjhj(Xj) is the pointwise variance function of ˆfj,
where Cov(ˆθj) = ˆΣjj is the appropriate sub-matrix of ˆΣ. The shaded region
in each panel is deﬁned by ˆfj(Xj)
2
The AIC statistic is slightly more generous than the likelihood-ratio test
p
(deviance test). Both sbp and obesity are included in this model, while

vj(Xj).

±

5.2 Piecewise Polynomials and Splines

147

)
o
c
c
a
b
o
t
(
ˆf

8

6

4

2

0

100

120

140

160
sbp

180

200

220

0

5

10

15

20
tobacco

25

30

2

4

6

10

12

14

8
ldl

Absent

famhist

Present

)
t
s
i
h
m
a
f
(
ˆf

)
e
g
a
(
ˆf

4

2

0

2
-

4
-

2

0

2
-

4
-

6
-

)
p
b
s
(
ˆf

)
l
d
l
(
ˆf

)
y
t
i
s
e
b
o
(
ˆf

4

2

0

2
-

4

2

0

2
-

4
-

6

4

2

0

2
-

15

20

25

30
35
obesity

40

45

20

30

50

60

40
age

FIGURE 5.4. Fitted natural-spline functions for each of the terms in the ﬁnal
model selected by the stepwise procedure. Included are pointwise standard-error
bands. The rug plot at the base of each ﬁgure indicates the location of each of the
sample values for that variable (jittered to break ties).

148

5. Basis Expansions and Regularization

TABLE 5.1. Final logistic regression model, after stepwise deletion of natural
splines terms. The column labeled “LRT” is the likelihood-ratio test statistic when
that term is deleted from the model, and is the change in deviance from the full
model (labeled “none”).

Terms Df Deviance
458.09
467.16
470.48
472.39
479.44
466.24
481.86

none
sbp
tobacco
ldl
famhist
obesity
age

4
4
4
1
4
4

AIC
502.09
503.16
506.48
508.39
521.44
502.24
517.86

LRT P-value

9.076
12.387
14.307
21.356
8.147
23.768

0.059
0.015
0.006
0.000
0.086
0.000

they were not in the linear model. The ﬁgure explains why, since their
contributions are inherently nonlinear. These eﬀects at ﬁrst may come as
a surprise, but an explanation lies in the nature of the retrospective data.
These measurements were made sometime after the patients suﬀered a
heart attack, and in many cases they had already beneﬁted from a healthier
diet and lifestyle, hence the apparent increase in risk at low values for
obesity and sbp. Table 5.1 shows a summary of the selected model.

5.2.3 Example: Phoneme Recognition

In this example we use splines to reduce ﬂexibility rather than increase it;
the application comes under the general heading of functional modeling. In
the top panel of Figure 5.5 are displayed a sample of 15 log-periodograms
for each of the two phonemes “aa” and “ao” measured at 256 frequencies.
The goal is to use such data to classify a spoken phoneme. These two
phonemes were chosen because they are diﬃcult to separate.

The input feature is a vector x of length 256, which we can think of as
a vector of evaluations of a function X(f ) over a grid of frequencies f . In
reality there is a continuous analog signal which is a function of frequency,
and we have a sampled version of it.

The gray lines in the lower panel of Figure 5.5 show the coeﬃcients of
a linear logistic regression model ﬁt by maximum likelihood to a training
sample of 1000 drawn from the total of 695 “aa”s and 1022 “ao”s. The
coeﬃcients are also plotted as a function of frequency, and in fact we can
think of the model in terms of its continuous counterpart

log

Pr(aa
Pr(ao

X)
X)

|
|

=

X(f )β(f )df,

(5.7)

Z

5.2 Piecewise Polynomials and Splines

149

Phoneme Examples

aa
ao

0

50

100

150

200

250

Frequency

Phoneme Classification: Raw and Restricted Logistic Regression

5
2

0
2

5
1

0
1

5

0

4
.
0

2
.
0

0
.
0

2
.
0
-

4
.
0
-

m
a
r
g
o
d
o
i
r
e
p
-
g
o
L

i

i

s
t
n
e
c
i
f
f
e
o
C
n
o
s
s
e
r
g
e
R
c
i
t
s
g
o
L

i

0

50

100

150

200

250

Frequency

FIGURE 5.5. The top panel displays the log-periodogram as a function of fre-
quency for 15 examples each of the phonemes “aa” and “ao” sampled from a total
of 695 “aa”s and 1022 “ao”s. Each log-periodogram is measured at 256 uniformly
spaced frequencies. The lower panel shows the coeﬃcients (as a function of fre-
quency) of a logistic regression ﬁt to the data by maximum likelihood, using the
256 log-periodogram values as inputs. The coeﬃcients are restricted to be smooth
in the red curve, and are unrestricted in the jagged gray curve.

 
 
150

5. Basis Expansions and Regularization

which we approximate by

256

j=1
X

256

X(fj)β(fj) =

xjβj.

(5.8)

j=1
X

The coeﬃcients compute a contrast functional, and will have appreciable
values in regions of frequency where the log-periodograms diﬀer between
the two classes.

The gray curves are very rough. Since the input signals have fairly strong
positive autocorrelation, this results in negative autocorrelation in the co-
eﬃcients. In addition the sample size eﬀectively provides only four obser-
vations per coeﬃcient.

Applications such as this permit a natural regularization. We force the
coeﬃcients to vary smoothly as a function of frequency. The red curve in the
lower panel of Figure 5.5 shows such a smooth coeﬃcient curve ﬁt to these
data. We see that the lower frequencies oﬀer the most discriminatory power.
Not only does the smoothing allow easier interpretation of the contrast, it
also produces a more accurate classiﬁer:

Training error
Test error

Raw Regularized
0.080
0.255

0.185
0.158

The smooth red curve was obtained through a very simple use of natural
cubic splines. We can represent the coeﬃcient function as an expansion of
M
m=1 hm(f )θm. In practice this means that β = Hθ where,
splines β(f ) =
H is a p
M basis matrix of natural cubic splines, deﬁned on the set of
frequencies. Here we used M = 12 basis functions, with knots uniformly
placed over the integers 1, 2, . . . , 256 representing the frequencies. Since
xT β = xT Hθ, we can simply replace the input features x by their ﬁltered
versions x∗ = HT x, and ﬁt θ by linear logistic regression on the x∗. The
red curve is thus ˆβ(f ) = h(f )T ˆθ.

P

×

5.3 Filtering and Feature Extraction

M basis matrix H, and then
In the previous example, we constructed a p
transformed our features x into new features x∗ = HT x. These ﬁltered
versions of the features were then used as inputs into a learning procedure:
in the previous example, this was linear logistic regression.

×

Preprocessing of high-dimensional features is a very general and pow-
erful method for improving the performance of a learning algorithm. The
preprocessing need not be linear as it was above, but can be a general

5.4 Smoothing Splines

151

(nonlinear) function of the form x∗ = g(x). The derived features x∗ can
then be used as inputs into any (linear or nonlinear) learning procedure.

For example, for signal or image recognition a popular approach is to ﬁrst
transform the raw features via a wavelet transform x∗ = HT x (Section 5.9)
and then use the features x∗ as inputs into a neural network (Chapter 11).
Wavelets are eﬀective in capturing discrete jumps or edges, and the neural
network is a powerful tool for constructing nonlinear functions of these
features for predicting the target variable. By using domain knowledge
to construct appropriate features, one can often improve upon a learning
method that has only the raw features x at its disposal.

5.4 Smoothing Splines

Here we discuss a spline basis method that avoids the knot selection prob-
lem completely by using a maximal set of knots. The complexity of the ﬁt
is controlled by regularization. Consider the following problem: among all
functions f (x) with two continuous derivatives, ﬁnd one that minimizes the
penalized residual sum of squares

N

RSS(f, λ) =

yi −
{

f (xi)

2 + λ
}

f ′′(t)
{

2dt,
}

Z

(5.9)

i=1
X

where λ is a ﬁxed smoothing parameter. The ﬁrst term measures closeness
to the data, while the second term penalizes curvature in the function, and
λ establishes a tradeoﬀ between the two. Two special cases are:

λ = 0 : f can be any function that interpolates the data.

λ =

: the simple least squares line ﬁt, since no second derivative can

∞
be tolerated.

These vary from very rough to very smooth, and the hope is that λ
indexes an interesting class of functions in between.

(0,

)

∞

∈

The criterion (5.9) is deﬁned on an inﬁnite-dimensional function space—
in fact, a Sobolev space of functions for which the second term is deﬁned.
Remarkably, it can be shown that (5.9) has an explicit, ﬁnite-dimensional,
unique minimizer which is a natural cubic spline with knots at the unique
values of the xi, i = 1, . . . , N (Exercise 5.7). At face value it seems that
the family is still over-parametrized, since there are as many as N knots,
which implies N degrees of freedom. However, the penalty term translates
to a penalty on the spline coeﬃcients, which are shrunk some of the way
toward the linear ﬁt.

Since the solution is a natural spline, we can write it as

N

f (x) =

Nj(x)θj,

j=1
X

(5.10)

152

5. Basis Expansions and Regularization

D
M
B

l

i

a
n
p
S
n

i

e
g
n
a
h
C
e
v
i
t
a
e
R

l

0
2
.
0

5
1
.
0

0
1
.
0

5
0
.
0

0
.
0

5
0
0
-

.

•

•

•

•

•

•

•
•
•
•
•
•
•
•

•
•

•
•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•

•

•

•

•

•

•

•
•
•
•
•
•
•
•

•
•

•
•
•
•
•

•
•
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•

•
•

•

•

•
•

•

•

•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
••
•
•

•
•
•
•

•

•

•

•

•
•

•
•

•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•

•
•

•

•

•

•

•
•
•

•

•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•
•
•

•
•
•
•
•
•
•

•
•

•
•
•
•
•
•

•
•

•

•

•

•

•

•

•

Male
Female

•
•
•
•
•
•
•
•
•
•
•
•
•

•

•

•
•
•
•
•
•
•
•

•
•
•
•

•

•

•

•

•
•
•
•
•
•
•
•

•
•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•

•
•

•
•

•
•

•

•
•
•
•
•
•
•
•

•
•
•
•
•
•

•
•

•
•
•

•

•
•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

10

15

20

25

Age

FIGURE 5.6. The response is the relative change in bone mineral density mea-
sured at the spine in adolescents, as a function of age. A separate smoothing spline
was ﬁt to the males and females, with λ
0.00022. This choice corresponds to
about 12 degrees of freedom.

≈

where the Nj(x) are an N -dimensional set of basis functions for repre-
senting this family of natural splines (Section 5.2.1 and Exercise 5.4). The
criterion thus reduces to

N
where
{
easily seen to be

}ij = Nj(xi) and

RSS(θ, λ) = (y

Nθ)T (y

Nθ) + λθT ΩN θ,

(5.11)

−

−
ΩN }jk =
{
ˆθ = (NT N + λΩN )−1NT y,

N ′′

j (t)N ′′

R

k (t)dt. The solution is

(5.12)

a generalized ridge regression. The ﬁtted smoothing spline is given by

N

ˆf (x) =

Nj(x)ˆθj.

(5.13)

j=1
X
Eﬃcient computational techniques for smoothing splines are discussed in
the Appendix to this chapter.

Figure 5.6 shows a smoothing spline ﬁt to some data on bone mineral
density (BMD) in adolescents. The response is relative change in spinal
BMD over two consecutive visits, typically about one year apart. The data
are color coded by gender, and two separate curves were ﬁt. This simple

 
 
 
 
5.4 Smoothing Splines

153

summary reinforces the evidence in the data that the growth spurt for
females precedes that for males by about two years. In both cases the
smoothing parameter λ was approximately 0.00022; this choice is discussed
in the next section.

5.4.1 Degrees of Freedom and Smoother Matrices

We have not yet indicated how λ is chosen for the smoothing spline. Later
in this chapter we describe automatic methods using techniques such as
cross-validation. In this section we discuss intuitive ways of prespecifying
the amount of smoothing.

A smoothing spline with prechosen λ is an example of a linear smoother
(as in linear operator). This is because the estimated parameters in (5.12)
are a linear combination of the yi. Denote by ˆf the N -vector of ﬁtted values
ˆf (xi) at the training predictors xi. Then

ˆf = N(NT N + λΩN )−1NT y

= Sλy.

(5.14)

Again the ﬁt is linear in y, and the ﬁnite linear operator Sλ is known as
the smoother matrix. One consequence of this linearity is that the recipe
for producing ˆf from y does not depend on y itself; Sλ depends only on
the xi and λ.

Linear operators are familiar in more traditional least squares ﬁtting as
M matrix of M cubic-spline basis functions
N .

well. Suppose Bξ is a N
evaluated at the N training points xi, with knot sequence ξ, and M
Then the vector of ﬁtted spline values is given by

≪

×

ˆf = Bξ(BT
= Hξy.

ξ Bξ)−1BT

ξ y

(5.15)

Here the linear operator Hξ is a projection operator, also known as the hat
matrix in statistics. There are some important similarities and diﬀerences
between Hξ and Sλ:

Both are symmetric, positive semideﬁnite matrices.

Sλ, meaning that the right-
HξHξ = Hξ (idempotent), while SλSλ (cid:22)
hand side exceeds the left-hand side by a positive semideﬁnite matrix.
This is a consequence of the shrinking nature of Sλ, which we discuss
further below.

Hξ has rank M , while Sλ has rank N .

•

•

•

The expression M = trace(Hξ) gives the dimension of the projection space,
which is also the number of basis functions, and hence the number of pa-
rameters involved in the ﬁt. By analogy we deﬁne the eﬀective degrees of

154

5. Basis Expansions and Regularization

freedom of a smoothing spline to be

dfλ = trace(Sλ),

(5.16)

the sum of the diagonal elements of Sλ. This very useful deﬁnition allows
us a more intuitive way to parameterize the smoothing spline, and indeed
many other smoothers as well, in a consistent fashion. For example, in Fig-
ure 5.6 we speciﬁed dfλ = 12 for each of the curves, and the corresponding
0.00022 was derived numerically by solving trace(Sλ) = 12. There are
λ
many arguments supporting this deﬁnition of degrees of freedom, and we
cover some of them here.

≈

Since Sλ is symmetric (and positive semideﬁnite), it has a real eigen-
decomposition. Before we proceed, it is convenient to rewrite Sλ in the
Reinsch form

where K does not depend on λ (Exercise 5.9). Since ˆf = Sλy solves

Sλ = (I + λK)−1,

(y

min
f

−

f )T (y

−

f ) + λf T Kf ,

(5.17)

(5.18)

K is known as the penalty matrix, and indeed a quadratic form in K has
a representation in terms of a weighted sum of squared (divided) second
diﬀerences. The eigen-decomposition of Sλ is

with

N

Sλ =

ρk(λ)ukuT
k

Xk=1

ρk(λ) =

1
1 + λdk

,

(5.19)

(5.20)

and dk the corresponding eigenvalue of K. Figure 5.7 (top) shows the re-
sults of applying a cubic smoothing spline to some air pollution data (128
observations). Two ﬁts are given: a smoother ﬁt corresponding to a larger
penalty λ and a rougher ﬁt for a smaller penalty. The lower panels repre-
sent the eigenvalues (lower left) and some eigenvectors (lower right) of the
corresponding smoother matrices. Some of the highlights of the eigenrep-
resentation are the following:

•

•

The eigenvectors are not aﬀected by changes in λ, and hence the whole
family of smoothing splines (for a particular sequence x) indexed by
λ have the same eigenvectors.

N
k=1 ukρk(λ)

Sλy =
uk, y
, and hence the smoothing spline oper-
ates by decomposing y w.r.t. the (complete) basis
, and diﬀer-
entially shrinking the contributions using ρk(λ). This is to be con-
trasted with a basis-regression method, where the components are

uk}
{

P

i

h

5.4 Smoothing Splines

155

•

n
o
i
t
a
r
t
n
e
c
n
o
C
e
n
o
z
O

0
3

0
2

0
1

0

•

•

•
•
• •

•

•

•
••

•

•
•

•
•

•

•

•

••
•
•

•

•
••
•

•
•
••

•

•
•••

••

•

•

•

•

•
•

•

•

•

•

•

•
•
•

•

•

•

•

•

•

•

•
•

•

•
•
•
•

•

•

•

•

••

0

•

•

•
•
•

•
•
••
•

•

•

•

•
•
•

••
•
•
• •
•
••
•
•
•

•

•
••
•
••

•
•

-50

•
•
•
•
•

•

•

•

•

•
•

•
•
•
•

•

•

50

100

Daggot Pressure Gradient

df=5
df=11

• • •
• • • • • •

•

•

•

•

•

•

•

•

•

•

•

•

• • • • • • • • • • •
• • • • • • • • • • • • • • • • • •

l

s
e
u
a
v
n
e
g
E

i

2

.

1

0

.

1

8

.

0

6
0

.

4
0

.

2

.

0

0

.

0

2

.

0
-

5

10

15

20

25

Order

-50

0

50

100

-50

0

50

100

FIGURE 5.7. (Top:) Smoothing spline ﬁt of ozone concentration versus Daggot
pressure gradient. The two ﬁts correspond to diﬀerent values of the smoothing
parameter, chosen to achieve ﬁve and eleven eﬀective degrees of freedom, deﬁned
by dfλ = trace(Sλ). (Lower left:) First 25 eigenvalues for the two smoothing-spline
0. (Lower right:) Third to
matrices. The ﬁrst two are exactly 1, and all are
sixth eigenvectors of the spline smoother matrices. In each case, uk is plotted
against x, and as such is viewed as a function of x. The rug at the base of the
plots indicate the occurrence of data points. The damped functions represent the
smoothed versions of these functions (using the 5 df smoother).

≥

 
156

5. Basis Expansions and Regularization

either left alone, or shrunk to zero—that is, a projection matrix such
as Hξ above has M eigenvalues equal to 1, and the rest are 0. For
this reason smoothing splines are referred to as shrinking smoothers,
while regression splines are projection smoothers (see Figure 3.17 on
page 80).

The sequence of uk, ordered by decreasing ρk(λ), appear to increase
in complexity. Indeed, they have the zero-crossing behavior of polyno-
mials of increasing degree. Since Sλuk = ρk(λ)uk, we see how each of
the eigenvectors themselves are shrunk by the smoothing spline: the
higher the complexity, the more they are shrunk. If the domain of X
is periodic, then the uk are sines and cosines at diﬀerent frequencies.

The ﬁrst two eigenvalues are always one, and they correspond to the
two-dimensional eigenspace of functions linear in x (Exercise 5.11),
which are never shrunk.

The eigenvalues ρk(λ) = 1/(1 + λdk) are an inverse function of the
eigenvalues dk of the penalty matrix K, moderated by λ; λ controls
the rate at which the ρk(λ) decrease to zero. d1 = d2 = 0 and again
linear functions are not penalized.

One can reparametrize the smoothing spline using the basis vectors
uk (the Demmler–Reinsch basis). In this case the smoothing spline
solves

2 + λθT Dθ,
k
where U has columns uk and D is a diagonal matrix with elements
dk.

(5.21)

θ k

min

Uθ

−

y

•

•

•

•

•

N
dfλ = trace(Sλ) =
k=1 ρk(λ). For projection smoothers, all the
eigenvalues are 1, each one corresponding to a dimension of the pro-
jection subspace.

P

Figure 5.8 depicts a smoothing spline matrix, with the rows ordered with
x. The banded nature of this representation suggests that a smoothing
spline is a local ﬁtting method, much like the locally weighted regression
procedures in Chapter 6. The right panel shows in detail selected rows of
I,
S, which we call the equivalent kernels. As λ
H, the
the N -dimensional identity matrix. As λ
hat matrix for linear regression on x.

N , and Sλ →

2, and Sλ →

→
, dfλ →

0, dfλ →

→ ∞

5.5 Automatic Selection of the Smoothing

Parameters

The smoothing parameters for regression splines encompass the degree of
the splines, and the number and placement of the knots. For smoothing

5.5 Automatic Selection of the Smoothing Parameters

157

Equivalent Kernels

•••• • • ••••••

Row 12

•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• •• •

Smoother Matrix

Row 25

••••••

•

•••• •

•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• •• •

Row 50

•••• • • •••••• •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• •• •

Row 75

•••• • • •••••• •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• •• •

Row 100

•••• • • •••••• •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• ••

•

Row 115

•••• • • •••••• •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• •• •

•

•

•

•

•

•

12

25

50

75

100

115

FIGURE 5.8. The smoother matrix for a smoothing spline is nearly banded,
indicating an equivalent kernel with local support. The left panel represents the
elements of S as an image. The right panel shows the equivalent kernel or weight-
ing function in detail for the indicated rows.

158

5. Basis Expansions and Regularization

splines, we have only the penalty parameter λ to select, since the knots are
at all the unique training X’s, and cubic degree is almost always used in
practice.

Selecting the placement and number of knots for regression splines can be
a combinatorially complex task, unless some simpliﬁcations are enforced.
The MARS procedure in Chapter 9 uses a greedy algorithm with some
additional approximations to achieve a practical compromise. We will not
discuss this further here.

5.5.1 Fixing the Degrees of Freedom

Since dfλ = trace(Sλ) is monotone in λ for smoothing splines, we can in-
vert the relationship and specify λ by ﬁxing df. In practice this can be
achieved by simple numerical methods. So, for example, in R one can use
smooth.spline(x,y,df=6) to specify the amount of smoothing. This encour-
ages a more traditional mode of model selection, where we might try a cou-
ple of diﬀerent values of df, and select one based on approximate F -tests,
residual plots and other more subjective criteria. Using df in this way pro-
vides a uniform approach to compare many diﬀerent smoothing methods.
It is particularly useful in generalized additive models (Chapter 9), where
several smoothing methods can be simultaneously used in one model.

5.5.2 The Bias–Variance Tradeoﬀ

Figure 5.9 shows the eﬀect of the choice of dfλ when using a smoothing
spline on a simple example:

Y = f (X) + ε,

f (X) =

sin(12(X + 0.2))
X + 0.2

,

(5.22)

with X
∼
pairs xi, yi drawn independently from this model.

U [0, 1] and ε

∼

N (0, 1). Our training sample consists of N = 100

The ﬁtted splines for three diﬀerent values of dfλ are shown. The yellow
shaded region in the ﬁgure represents the pointwise standard error of ˆfλ,
se( ˆfλ(x)). Since
that is, we have shaded the region between ˆfλ(x)
ˆf = Sλy,

±

2

·

Cov(ˆf ) = SλCov(y)ST
λ
= SλST
λ .

(5.23)

The diagonal contains the pointwise variances at the training xi. The bias
is given by

Bias(ˆf ) = f
= f

E(ˆf )
Sλf ,

−
−

(5.24)

5.5 Automatic Selection of the Smoothing Parameters

159

Cross-Validation

CV
EPE

y

2

0

2
−

4
−

dfλ = 5

O

O
O

O

O
O
O

O

O

O
O
OO
O
O

O

O

OOO
O
O
O

O

O

O

O
O
O
O

O

O

O
O

O

O

O

O

O

O

O

O

O

O

O

O
OO
O

O

O

O

O
OO

O
O
OO

O

O
O

O
O
O

O

O

O

O

OO
O

O

OO

O

O

O

O

O

O

O

O

O

O

O
O
O
O
OO
O

O

O

O

O

O
O
O

O

6

8

10

12

14

0.0

0.2

0.4

0.6

0.8

1.0

dfλ

dfλ = 9

O

O
O

O

O
O
O

O

O

O
O
OO
O
O

O

O

OOO
O
O
O

O

O

O

O
O
O
O

O

O

O
O

O

O

O

O

O

O

O

O

O

O

O

O
OO
O

O

O

O

O
OO

O
O
OO

O

O
O

O
O
O

O

O

O

O

OO
O

O

OO

O

O

O

O

O

O

O

O

O

O

O
O
O
O
OO
O

O

O

O
O
O

O

O

O

y

X

dfλ = 15

O

O
O

O

O
O
O

O

O

O
O
OO
O
O

O

O

OOO
O
O
O

O

O

O

O
O
O
O

O

O

O
O

O

O

O

O

O

O

O

O

O

O

O

O
OO
O

O

O

O

O
OO

O
O
OO

O

O
O

O
O
O

O

O

O

2

0

2
−

4
−

O

OO
O

O

OO

O

O

O

O

O

O

O

O

O

O

O
O
O
O
OO
O

O

O

O

O

O
O
O

O

)
λ
(
V
C
d
n
a

)
λ
(
E
P
E

y

5
1

.

4

.

1

3

.

1

2
1

.

1

.

1

0
.
1

2

0

2
−

4
−

0.0

0.2

0.4

0.6

0.8

1.0

0.0

0.2

0.4

0.6

0.8

1.0

X

X

FIGURE 5.9. The top left panel shows the EPE(λ) and CV(λ) curves for a
realization from a nonlinear additive error model (5.22). The remaining panels
show the data, the true functions (in purple), and the ﬁtted curves (in green) with
yellow shaded

standard error bands, for three diﬀerent values of dfλ.

2

±

×

160

5. Basis Expansions and Regularization

where f is the (unknown) vector of evaluations of the true f at the training
X’s. The expectations and variances are with respect to repeated draws
of samples of size N = 100 from the model (5.22). In a similar fashion
Var( ˆfλ(x0)) and Bias( ˆfλ(x0)) can be computed at any point x0 (Exer-
cise 5.10). The three ﬁts displayed in the ﬁgure give a visual demonstration
of the bias-variance tradeoﬀ associated with selecting the smoothing
parameter.

dfλ = 5: The spline under ﬁts, and clearly trims down the hills and ﬁlls in
the valleys. This leads to a bias that is most dramatic in regions of
high curvature. The standard error band is very narrow, so we esti-
mate a badly biased version of the true function with great reliability!

dfλ = 9: Here the ﬁtted function is close to the true function, although a
slight amount of bias seems evident. The variance has not increased
appreciably.

dfλ = 15: The ﬁtted function is somewhat wiggly, but close to the true
function. The wiggliness also accounts for the increased width of the
standard error bands—the curve is starting to follow some individual
points too closely.

Note that in these ﬁgures we are seeing a single realization of data and
hence ﬁtted spline ˆf in each case, while the bias involves an expectation
E( ˆf ). We leave it as an exercise (5.10) to compute similar ﬁgures where the
bias is shown as well. The middle curve seems “just right,” in that it has
achieved a good compromise between bias and variance.

The integrated squared prediction error (EPE) combines both bias and

variance in a single summary:

EPE( ˆfλ) = E(Y

−

ˆfλ(X))2

= Var(Y ) + E

Bias2( ˆfλ(X)) + Var( ˆfλ(X))

= σ2 + MSE( ˆfλ).

h

i

(5.25)

Note that this is averaged both over the training sample (giving rise to ˆfλ),
and the values of the (independently chosen) prediction points (X, Y ). EPE
is a natural quantity of interest, and does create a tradeoﬀ between bias
and variance. The blue points in the top left panel of Figure 5.9 suggest
that dfλ = 9 is spot on!

Since we don’t know the true function, we do not have access to EPE, and
need an estimate. This topic is discussed in some detail in Chapter 7, and
techniques such as K-fold cross-validation, GCV and Cp are all in common
use. In Figure 5.9 we include the N -fold (leave-one-out) cross-validation
curve:

5.6 Nonparametric Logistic Regression

161

CV( ˆfλ) =

=

1
N

1
N

N

i=1
X
N

i=1  
X

(yi −

ˆf (−i)
λ

(xi))2

ˆfλ(xi)
Sλ(i, i) !

yi −
1
−

2

,

(5.26)

(5.27)

which can (remarkably) be computed for each value of λ from the original
ﬁtted values and the diagonal elements Sλ(i, i) of Sλ (Exercise 5.13).

The EPE and CV curves have a similar shape, but the entire CV curve
is above the EPE curve. For some realizations this is reversed, and overall
the CV curve is approximately unbiased as an estimate of the EPE curve.

5.6 Nonparametric Logistic Regression

The smoothing spline problem (5.9) in Section 5.4 is posed in a regression
setting. It is typically straightforward to transfer this technology to other
domains. Here we consider logistic regression with a single quantitative
input X. The model is

which implies

log

Pr(Y = 1
|
Pr(Y = 0
|

X = x)
X = x)

= f (x),

(5.28)

Pr(Y = 1
|

X = x) =

ef (x)
1 + ef (x) .

(5.29)

Fitting f (x) in a smooth fashion leads to a smooth estimate of the condi-
x), which can be used for classiﬁcation or risk
tional probability Pr(Y = 1
|
scoring.

We construct the penalized log-likelihood criterion

ℓ(f ; λ) =

N

i=1
X
N

[yi log p(xi) + (1

yi) log(1

p(xi))]

−

−

1
2

λ

−

Z

f ′′(t)
{

2dt
}

=

i=1 h
X

yif (xi)

−

log(1 + ef (xi))

1
2

λ

Z

−

i

f ′′(t)
{

2dt,
}

(5.30)

where we have abbreviated p(x) = Pr(Y = 1
x). The ﬁrst term in this ex-
|
pression is the log-likelihood based on the binomial distribution (c.f. Chap-
ter 4, page 120). Arguments similar to those used in Section 5.4 show that
the optimal f is a ﬁnite-dimensional natural spline with knots at the unique

162

5. Basis Expansions and Regularization

values of x. This means that we can represent f (x) =
compute the ﬁrst and second derivatives

N
j=1 Nj(x)θj. We

P

∂ℓ(θ)
∂θ
∂2ℓ(θ)
∂θ∂θT =

= NT (y

p)

−

−

λΩθ,

NT WN

−

λΩ,

−

(5.31)

(5.32)

where p is the N -vector with elements p(xi), and W is a diagonal matrix
of weights p(xi)(1
p(xi)). The ﬁrst derivative (5.31) is nonlinear in θ, so
we need to use an iterative algorithm as in Section 4.4.1. Using Newton–
Raphson as in (4.23) and (4.26) for linear logistic regression, the update
equation can be written

−

θnew = (NT WN + λΩ)−1NT W

Nθold + W−1(y

= (NT WN + λΩ)−1NT Wz.
(cid:0)

We can also express this update in terms of the ﬁtted values

f new = N(NT WN + λΩ)−1NT W

f old + W−1(y

= Sλ,wz.

(cid:0)

p)

−

(5.33)

(cid:1)

p)

−

(5.34)

(cid:1)

Referring back to (5.12) and (5.14), we see that the update ﬁts a weighted
smoothing spline to the working response z (Exercise 5.12).

The form of (5.34) is suggestive. It is tempting to replace Sλ,w by any
nonparametric (weighted) regression operator, and obtain general fami-
lies of nonparametric logistic regression models. Although here x is one-
dimensional, this procedure generalizes naturally to higher-dimensional x.
These extensions are at the heart of generalized additive models, which we
pursue in Chapter 9.

5.7 Multidimensional Splines

So far we have focused on one-dimensional spline models. Each of the ap-
IR2, and we have
proaches have multidimensional analogs. Suppose X
a basis of functions h1k(X1), k = 1, . . . , M1 for representing functions of
coordinate X1, and likewise a set of M2 functions h2k(X2) for coordinate
X2. Then the M1 ×

M2 dimensional tensor product basis deﬁned by

∈

gjk(X) = h1j(X1)h2k(X2), j = 1, . . . , M1, k = 1, . . . , M2

(5.35)

can be used for representing a two-dimensional function:

M1

M2

g(X) =

θjkgjk(X).

(5.36)

j=1
X

Xk=1

5.7 Multidimensional Splines

163

FIGURE 5.10. A tensor product basis of B-splines, showing some selected pairs.
Each two-dimensional function is the tensor product of the corresponding one
dimensional marginals.

Figure 5.10 illustrates a tensor product basis using B-splines. The coeﬃ-
cients can be ﬁt by least squares, as before. This can be generalized to d
dimensions, but note that the dimension of the basis grows exponentially
fast—yet another manifestation of the curse of dimensionality. The MARS
procedure discussed in Chapter 9 is a greedy forward algorithm for includ-
ing only those tensor products that are deemed necessary by least squares.

Figure 5.11 illustrates the diﬀerence between additive and tensor product
(natural) splines on the simulated classiﬁcation example from Chapter 2.
x)] = h(x)T θ is ﬁt to the binary re-
A logistic regression model logit[Pr(T
|
sponse, and the estimated decision boundary is the contour h(x)T ˆθ = 0.
The tensor product basis can achieve more ﬂexibility at the decision bound-
ary, but introduces some spurious structure along the way.

164

5. Basis Expansions and Regularization

Additive Natural Cubic Splines - 4 df each

o

o

o

o

o

o

o

o

o
o

o
o

. . .. .. .. ...

o
o

o
o
o

o
o
o
o
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
oo
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
oo
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
oo
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
oo
o
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.. .. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.23
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.28
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.21

o
o
o
o
o

o
o
o
o

o
o

o
o
o

o
o

o
o
o

o
o

o

o

o

o

o

o

Natural Cubic Splines - Tensor Product - 4 df each

o

o

o

o

o

o

o

o

o

o

o

o
o

o
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
oo
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
oo
. . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . ..
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
Training Error: 0.230
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
Test Error:       0.282
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o
o

o
o
o

o
o
o

o
o

o

o

o

o

o

o

o

o

FIGURE 5.11. The simulation example of Figure 2.1. The upper panel shows the
decision boundary of an additive logistic regression model, using natural splines
in each of the two coordinates (total df = 1 + (4
1) = 7). The lower
panel shows the results of using a tensor product of natural spline bases in each
4 = 16). The broken purple boundary is the Bayes
coordinate (total df = 4
decision boundary for this problem.

1) + (4

−

−

×

5.7 Multidimensional Splines

165

One-dimensional smoothing splines (via regularization) generalize to high-
IRd, and we
er dimensions as well. Suppose we have pairs yi, xi with xi ∈
seek a d-dimensional regression function f (x). The idea is to set up the
problem

N

min
f

yi −
{

f (xi)

2 + λJ[f ],
}

(5.37)

i=1
X

where J is an appropriate penalty functional for stabilizing a function f in
IRd. For example, a natural generalization of the one-dimensional roughness
penalty (5.9) for functions on IR2 is

2

2

2

+ 2

J[f ] =

Z ZIR2

∂2f (x)
∂x2

∂2f (x)
∂x1∂x2 (cid:19)
Optimizing (5.37) with this penalty leads to a smooth two-dimensional
surface, known as a thin-plate spline. It shares many properties with the
one-dimensional cubic smoothing spline:

∂2f (x)
∂x2

dx1dx2. (5.38)

1 (cid:19)

2 (cid:19)

h(cid:18)

+

(cid:18)

(cid:18)

i

•

•

•

0, the solution approaches an interpolating function [the one

as λ
with smallest penalty (5.38)];

→

as λ

→ ∞

, the solution approaches the least squares plane;

for intermediate values of λ, the solution can be represented as a
linear expansion of basis functions, whose coeﬃcients are obtained
by a form of generalized ridge regression.

The solution has the form

f (x) = β0 + βT x +

αjhj(x),

(5.39)

N

j=1
X

2 log

||

||

x

x

−

xj||

where hj(x) =
. These hj are examples of radial
xj||
basis functions, which are discussed in more detail in the next section. The
coeﬃcients are found by plugging (5.39) into (5.37), which reduces to a
ﬁnite-dimensional penalized least squares problem. For the penalty to be
ﬁnite, the coeﬃcients αj have to satisfy a set of linear constraints; see
Exercise 5.14.

−

Thin-plate splines are deﬁned more generally for arbitrary dimension d,

for which an appropriately more general J is used.

There are a number of hybrid approaches that are popular in practice,
both for computational and conceptual simplicity. Unlike one-dimensional
smoothing splines, the computational complexity for thin-plate splines is
O(N 3), since there is not in general any sparse structure that can be ex-
ploited. However, as with univariate smoothing splines, we can get away
with substantially less than the N knots prescribed by the solution (5.39).

166

5. Basis Expansions and Regularization

Systolic Blood Pressure

y
t
i
s
e
b
O

45

40

35

30

25

20

15

•

•

•

•

•

•
•
•

•
•

•

•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•

•

•

•

•

•

•
•
•
•

•

•

•

•
•

•
•
•

•
•
•
•
•

•

•

•

•

•

•

•

•

•
•
•
•
•
•
•
•
•
•

•

•

•

•

•
•
•
•
•
•
•
•
•

•

•
•

•

•

•
•

•
•

•

•

•
125

•
•

•
•
•

•

•

•
•

•

•
•
•
•

•
•
•
•
•

•
•
•

•

•

•
•
•
•

•
•
•
•

•
•
•
•
•
•
•

•

•
•
•

20

30

•

•

•

•

•
•

•

•
•
•
•
•
•
•

•
•
•

•
•
•

•

•

•

•

•
•
•
•
•
•
•
•
•
•

•
•

•
•
•
•
•
•

•
•

•

•
•
•
•
•

•

•

•

•

•

•

•

•

•

•
•
•

•
•

•
•
•
•
•
•
•
•
•
•

•

•

•

•
•
•
•

•
•
•

•
•

•

•
•
•

•
•
•
•
•
•
•
•

•

40

Age

•

•

•

•

•

•

•

•
•

•

•

•
•
•
•
•
•
•
•
•
•

•

•
•
•
•
•
•

•
•

•
•

•
•

•
•
•
•
•
•
•
•
•
•

•

•

•
•
•

•

•
•
•

•
•

•
•
•
•

•

•

•
•
•

•
•
•
•
•

•
•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•

•
•

•

•
•
•
•
•
•

•
•
•

•
•
•
•
•
•
•

•
•
•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
• •

•
•
•

•

•

•

•
•
•

•
•
•
•
•
•
•
•

•
•
•
•
•

•
•

•

•

•

•

•

•

•
155
•
•
•

•

•
•

•
•
•
•
•
•
•
•
•
•

•
•

•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
140

•
•
•
•
•
•

•
•
•

•

•
•

•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
150
•
•
•
•
•
•
•
•
•
•
•
145

•

135

•

•

60

•
130

•

50

160

155

150

145

140

135

130

125

120

FIGURE 5.12. A thin-plate spline ﬁt to the heart disease data, displayed as a
contour plot. The response is systolic blood pressure, modeled as a function
of age and obesity. The data points are indicated, as well as the lattice of points
used as knots. Care should be taken to use knots from the lattice inside the convex
hull of the data (red), and ignore those outside (green).

In practice, it is usually suﬃcient to work with a lattice of knots covering
the domain. The penalty is computed for the reduced expansion just as
before. Using K knots reduces the computations to O(N K 2 + K 3). Fig-
ure 5.12 shows the result of ﬁtting a thin-plate spline to some heart disease
risk factors, representing the surface as a contour plot. Indicated are the
location of the input features, as well as the knots used in the ﬁt. Note that
λ was speciﬁed via dfλ = trace(Sλ) = 15.
More generally one can represent f

IRd as an expansion in any arbi-
trarily large collection of basis functions, and control the complexity by ap-
plying a regularizer such as (5.38). For example, we could construct a basis
by forming the tensor products of all pairs of univariate smoothing-spline
basis functions as in (5.35), using, for example, the univariate B-splines
recommended in Section 5.9.2 as ingredients. This leads to an exponential

∈

5.8 Regularization and Reproducing Kernel Hilbert Spaces

167

growth in basis functions as the dimension increases, and typically we have
to reduce the number of functions per coordinate accordingly.

The additive spline models discussed in Chapter 9 are a restricted class
of multidimensional splines. They can be represented in this general formu-
lation as well; that is, there exists a penalty J[f ] that guarantees that the
+ fd(Xd) and that each of
solution has the form f (X) = α + f1(X1) +
the functions fj are univariate splines. In this case the penalty is somewhat
degenerate, and it is more natural to assume that f is additive, and then
simply impose an additional penalty on each of the component functions:

· · ·

J[f ] = J(f1 + f2 +
d

+ fd)

· · ·
j (tj)2dtj.
f ′′

=

j=1 Z
X

(5.40)

These are naturally extended to ANOVA spline decompositions,

f (X) = α +

fj(Xj) +

fjk(Xj, Xk) +

j
X

Xj<k

,

· · ·

(5.41)

where each of the components are splines of the required dimension. There
are many choices to be made:

The maximum order of interaction—we have shown up to order 2
above.

Which terms to include—not all main eﬀects and interactions are
necessarily needed.

What representation to use—some choices are:

•

•

•

– regression splines with a relatively small number of basis func-
tions per coordinate, and their tensor products for interactions;
– a complete basis as in smoothing splines, and include appropri-

ate regularizers for each term in the expansion.

In many cases when the number of potential dimensions (features) is large,
automatic methods are more desirable. The MARS and MART procedures
(Chapters 9 and 10, respectively), both fall into this category.

5.8 Regularization and Reproducing Kernel

Hilbert Spaces

In this section we cast splines into the larger context of regularization meth-
ods and reproducing kernel Hilbert spaces. This section is quite technical
and can be skipped by the disinterested or intimidated reader.

168

5. Basis Expansions and Regularization

A general class of regularization problems has the form

N

min
f ∈H "

L(yi, f (xi)) + λJ(f )

#

(5.42)

i=1
X

where L(y, f (x)) is a loss function, J(f ) is a penalty functional, and
is
a space of functions on which J(f ) is deﬁned. Girosi et al. (1995) describe
quite general penalty functionals of the form

H

2

˜f (s)
|
˜G(s)

|

J(f ) =

ds,

(5.43)

ZIRd
where ˜f denotes the Fourier transform of f , and ˜G is some positive function
. The idea is that 1/ ˜G increases the penalty
that falls oﬀ to zero as
for high-frequency components of f . Under some additional assumptions
they show that the solutions have the form

|| → ∞

||

s

K

N

f (X) =

αkφk(X) +

θiG(X

Xk=1

i=1
X

xi),

−

(5.44)

where the φk span the null space of the penalty functional J, and G is the
inverse Fourier transform of ˜G. Smoothing splines and thin-plate splines
fall into this framework. The remarkable feature of this solution is that
while the criterion (5.42) is deﬁned over an inﬁnite-dimensional space, the
solution is ﬁnite-dimensional. In the next sections we look at some speciﬁc
examples.

5.8.1 Spaces of Functions Generated by Kernels

An important subclass of problems of the form (5.42) are generated by
a positive deﬁnite kernel K(x, y), and the corresponding space of func-
tions
HK is called a reproducing kernel Hilbert space (RKHS). The penalty
functional J is deﬁned in terms of the kernel as well. We give a brief and
simpliﬁed introduction to this class of models, adapted from Wahba (1990)
and Girosi et al. (1995), and nicely summarized in Evgeniou et al. (2000).
IRp. We consider the space of functions generated by the linear
∈
; i.e arbitrary linear combinations of the form
, y), y
K(
span of
}
{
m αmK(x, ym), where each kernel term is viewed as a function
f (x) =
of the ﬁrst argument, and indexed by the second. Suppose that K has an
eigen-expansion

Let x, y

IRp)

P

∈

·

∞

∞
i=1 γ2
0,
with γi ≥
these eigen-functions,

i <

P

K(x, y) =

γiφi(x)φi(y)

(5.45)

i=1
X

. Elements of

∞

∞

HK have an expansion in terms of

f (x) =

ciφi(x),

(5.46)

i=1
X

5.8 Regularization and Reproducing Kernel Hilbert Spaces

169

with the constraint that

2
HK

f

||

||

def=

∞

i=1
X

c2
i /γi <

,

∞

(5.47)

f

||HK is the norm induced by K. The penalty functional in (5.42)
where
||
2
HK . The
HK is deﬁned to be the squared norm J(f ) =
for the space
quantity J(f ) can be interpreted as a generalized ridge penalty, where
functions with large eigenvalues in the expansion (5.45) get penalized less,
and vice versa.

||

||

f

Rewriting (5.42) we have

min
f ∈HK "

N

i=1
X

L(yi, f (xi)) + λ

2
HK

f

||

||

#

(5.48)

or equivalently

min
{cj }∞

1 

N

∞

L(yi,

cjφj(xi)) + λ

i=1
X

j=1
X

∞

j=1
X



c2
j /γj


.

(5.49)

It can be shown (Wahba, 1990, see also Exercise 5.15) that the solution

to (5.48) is ﬁnite-dimensional, and has the form

N

f (x) =

αiK(x, xi).

i=1
X

(5.50)

The basis function hi(x) = K(x, xi) (as a function of the ﬁrst argument) is
∈ HK, it is
known as the representer of evaluation at xi in
iHK =
, xj)
easily seen that
, xi), f
K(
·
·
K(xi, xj) (the reproducing property of

HK , since for f
K(
, xi), K(
·
HK), and hence

iHK = f (xi). Similarly

h

h

N

N

J(f ) =

K(xi, xj)αiαj

(5.51)

i=1
X

j=1
X

for f (x) =

N
i=1 αiK(x, xi).

rion

P

In light of (5.50) and (5.51), (5.48) reduces to a ﬁnite-dimensional crite-

min
α

L(y, Kα) + λαT Kα.

(5.52)

We are using a vector notation, in which K is the N
N matrix with ijth
entry K(xi, xj) and so on. Simple numerical algorithms can be used to
optimize (5.52). This phenomenon, whereby the inﬁnite-dimensional prob-
lem (5.48) or (5.49) reduces to a ﬁnite dimensional optimization problem,
has been dubbed the kernel property in the literature on support-vector
machines (see Chapter 12).

×

170

5. Basis Expansions and Regularization

There is a Bayesian interpretation of this class of models, in which f
is interpreted as a realization of a zero-mean stationary Gaussian process,
with prior covariance function K. The eigen-decomposition produces a se-
ries of orthogonal eigen-functions φj(x) with associated variances γj. The
typical scenario is that “smooth” functions φj have large prior variance,
while “rough” φj have small prior variances. The penalty in (5.48) is the
contribution of the prior to the joint likelihood, and penalizes more those
components with smaller prior variance (compare with (5.43)).

H

For simplicity we have dealt with the case here where all members of
H
are penalized, as in (5.48). More generally, there may be some components
in
that we wish to leave alone, such as the linear functions for cubic
smoothing splines in Section 5.4. The multidimensional thin-plate splines
of Section 5.7 and tensor product splines fall into this category as well.
In these cases there is a more convenient representation
H0 ⊕ H1,
H0 consisting of, for example, low degree polynomi-
with the null space
als in x that do not get penalized. The penalty becomes J(f ) =
,
P1f
k
k
where P1 is the orthogonal projection of f onto
H1. The solution has the
N
form f (x) =
i=1 αiK(x, xi), where the ﬁrst term repre-
H0. From a Bayesian perspective, the coeﬃcients of
sents an expansion in
P
components in

H0 have improper priors, with inﬁnite variance.

M
j=1 βjhj(x) +

P

H

=

5.8.2 Examples of RKHS

The machinery above is driven by the choice of the kernel K and the loss
function L. We consider ﬁrst regression using squared-error loss. In this
case (5.48) specializes to penalized least squares, and the solution can be
characterized in two equivalent ways corresponding to (5.49) or (5.52):

min
{cj }∞
1

N

∞

yi −





i=1
X

j=1
X

cjφj(xi)

2





+ λ

c2
j
γj

∞

j=1
X

an inﬁnite-dimensional, generalized ridge regression problem, or

min
α

(y

−

Kα)T (y

−

Kα) + λαT Kα.

The solution for α is obtained simply as

ˆα = (K + λI)−1y,

and

(5.53)

(5.54)

(5.55)

ˆf (x) =

N

j=1
X

ˆαjK(x, xj).

(5.56)

5.8 Regularization and Reproducing Kernel Hilbert Spaces

171

The vector of N ﬁtted values is given by

ˆf = K ˆα

= K(K + λI)−1y
= (I + λK−1)−1y.

(5.57)
(5.58)

The estimate (5.57) also arises as the kriging estimate of a Gaussian ran-
dom ﬁeld in spatial statistics (Cressie, 1993). Compare also (5.58) with the
smoothing spline ﬁt (5.17) on page 154.

Penalized Polynomial Regression

The kernel K(x, y) = (
M =
total degree d. For example, with p = 2 and d = 2, M = 6 and

IRp, has
eigen-functions that span the space of polynomials in IRp of

+ 1)d (Vapnik, 1996), for x, y

p+d
d

x, y

∈

i

h

(cid:0)

(cid:1)

K(x, y) = 1 + 2x1y1 + 2x2y2 + x2

1y2

1 + x2

2y2

2 + 2x1x2y1y2 (5.59)

M

=

hm(x)hm(y)

m=1
X

with

h(x)T = (1, √2x1, √2x2, x2

1, x2

2, √2x1x2).

(5.60)

(5.61)

One can represent h in terms of the M orthogonal eigen-functions and
eigenvalues of K,

h(x) = VD

1
2

γ φ(x),

(5.62)

where Dγ = diag(γ1, γ2, . . . , γM ), and V is M

M and orthogonal.

Suppose we wish to solve the penalized polynomial regression problem

×

min
{βm}M
1

N

M

yi −

i=1  
X

m=1
X

βmhm(xi)

2

!

M

+ λ

β2
m.

m=1
X

(5.63)

Substituting (5.62) into (5.63), we get an expression of the form (5.53) to
optimize (Exercise 5.16).

The number of basis functions M =

can be very large, often much
larger than N . Equation (5.55) tells us that if we use the kernel represen-
tation for the solution function, we have only to evaluate the kernel N 2
times, and can compute the solution in O(N 3) operations.

(cid:0)

(cid:1)

p+d
d

This simplicity is not without implications. Each of the polynomials hm
in (5.61) inherits a scaling factor from the particular form of K, which has
a bearing on the impact of the penalty in (5.63). We elaborate on this in
the next section.

172

5. Basis Expansions and Regularization

Radial Kernel in IR1

)
m
x

,

·

(

K

8
.
0

4
.
0

0
.
0

−2

−1

0

1

X

2

3

4

FIGURE 5.13. Radial kernels kk(x) for the mixture data, with scale parameter
ν = 1. The kernels are centered at ﬁve points xm chosen at random from the 200.

Gaussian Radial Basis Functions

In the preceding example, the kernel is chosen because it represents an
expansion of polynomials and can conveniently compute high-dimensional
inner products. In this example the kernel is chosen because of its functional
form in the representation (5.50).

The Gaussian kernel K(x, y) = e−ν||x−y||2

along with squared-error loss,
for example, leads to a regression model that is an expansion in Gaussian
radial basis functions,

km(x) = e−ν||x−xm||2

, m = 1, . . . , N,

(5.64)

each one centered at one of the training feature vectors xm. The coeﬃcients
are estimated using (5.54).

Figure 5.13 illustrates radial kernels in IR1 using the ﬁrst coordinate of
the mixture example from Chapter 2. We show ﬁve of the 200 kernel basis
functions km(x) = K(x, xm).

∈

IR1. We computed the 200

Figure 5.14 illustrates the implicit feature space for the radial kernel
200 kernel matrix K, and its eigen-
with x
×
decomposition ΦDγΦT . We can think of the columns of Φ and the corre-
sponding eigenvalues in Dγ as empirical estimates of the eigen expansion
(5.45)2. Although the eigenvectors are discrete, we can represent them as
functions on IR1 (Exercise 5.17). Figure 5.15 shows the largest 50 eigenval-
ues of K. The leading eigenfunctions are smooth, and they are successively
more wiggly as the order increases. This brings to life the penalty in (5.49),
where we see the coeﬃcients of higher-order functions get penalized more
than lower-order ones. The right panel in Figure 5.14 shows the correspond-

2The ℓth column of Φ is an estimate of φℓ, evaluated at each of the N observations.
Alternatively, the ith row of Φ is the estimated vector of basis functions φ(xi), evaluated
at the point xi. Although in principle, there can be inﬁnitely many elements in φ, our
estimate has at most N elements.

5.8 Regularization and Reproducing Kernel Hilbert Spaces

173

Orthonormal Basis Φ

Feature Space H

*
*
*
*
**
*
*
*

*
*

*
*
*
*
*
*
*
*
*
***
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
**
**
*
*
*
*
*
*
*
*
*
**
*
**
*
*
*
*
*
*
***
*
* *
*
*
*
*
**
*
*
******
*
*
*
*
*
*
**
*
*
*** *** *
*
**
*
*
*
*
* *
*
*
*
*
*
*
* *
**
*
*
**
*
**
**
**
*
*
*
*
**
*
** *
**
*
**
*
*
*
* *
*
*
*
*
*
**
*
*
* **
*
*
*
*
*
**
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*

**
*
*
*

*

*
*
*
*
**
*
*
*

*
*

*
*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
*
*

*

*
*
*
*
*
*
*
*
**
*
**
*
*
* *
***
*
*
**
*
**
****
*** *** *
*
*
*
*
**
*
**
*
*
*
*
*
**
*
*
* *
*
** *
**
*
*
*
**
*
*
*
*
*
*
**
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
* *
*
*
*
* **
* *
*
**
*
**
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
**
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
***
*
*
*
*
*
*

**
*
*
*

*

*
*
*
*
*
*
**
*

*

*
*

***
*
*
*
*
*
*
*
*
*
*
*
*
*
**
**
* *
**
*
*
*
**
*
**
**
**
*
*
**
*
* *
*
*
** *
**
*** *** *
*
*
*
*
**
*
*
*
*
*
* *
*
*
*
**
*
* *
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
* **
******
*
***
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
**
**
**
*
**
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

**
*
*
*

**
*
*
*
*
*
*
*

*
*
*
*
**
**
*
*
*
*
*
*
*
*
*
******
*
*
*
*
*
*
**
*
*
*
*
*
*
* *
*
**
*** *** *
*
**
* *
*
*
**
*
*
* **
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
**
*
*
*
**
*
**
*
*
**
*
*
**
*
**
*
*
*
*
*
*
*
*
* *
*
***
***
*
** *
*
*
**
*
**
*
*
*
**
*
* *
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*

*
*

*
**
*
*

*

*

*
*

*
*
*
**
*
*
**
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**
**
*
*
*
*
*
*
*
*
** *
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
**
*
*
*
*
***
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*

*
*

*

*
*
*
*
*
*
**
*

*
*

*
*
*
*
*
*
*
*
*
*
*
*
*
*
* **
*
*
*
**
* *
***
*
*
*
**
******
**
*
*
**
*** *** *
*
*
*
*
*
** *
*
*
**
*
**
*
*
*
* *
*
*
*
*
*
*
* *
**
*
*
**
*
**
*
*
*
*
*
*
*
*
*
**
*
**
*
*
*
*
*
*
***
*
*
*
*
*
* *
*
**
**
*
*
*
*
*
*
*
*
**
*
*
*
*
*
**
*
*
*
*
**
*
**
**
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
**
*
*

*

*
*
**
*
*
*
*
*

*
*

*
*
***
*
*
*
*
*
*
*
*
*
*
*
*
*
**
**
*
*
* *
*
**
*
*
*
* *
*
*
******
**
**
*** *** *
*
*
*
*
*
***
*
* *
*
*
*
**
*
**
** *
*
*
*
*
*
*
*
*
*
*
*
*
*
**
* *
*
**
*
*
*
*
*
*
**
*
*
*
**
*
**
*
*
*
*
*
*
* **
*
*
*
*
**
*
**
*
*
**
*
*
**
**
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
**
*
*

*

*
*
**
*
*
*
*
*

*
*

*
*
***
*
*
*
*
*
*
*
*** *** *
* **
******
*
*
*
*
*
*
*
*
*
**
*
*
**
*
**
*
*
**
***
**
*
*
* *
**
*
*
*
*
*
*
* *
*
*
*
** *
*
*
*
*
*
**
*
*
*
*
**
*
*
*
*
* *
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
**
* *
**
*
**
**
*
*
*
*
**
**
*
*
*
*
*
*
**
*
*
*
*
*
*
**
*
*
*
*
**
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

**
*
*
*

*

*
*
**
*
*
*
*
*

*
*

*
*
*
*
**
*
*
*
**
*
*
**
*
**
*
*
**
*
* *
*
**
*
*
***
*
* *
*
******
*
*
**
*
* *
**
**
**
** *
**
*
*
**
*
*
*
**
**
*** *** *
*
*
***
* **
*
*
* *
*
*
*
*
*
*
*
*
*
**
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
**
*
*

*

×

FIGURE 5.14. (Left panel) The ﬁrst 16 normalized eigenvectors of K, the
200 kernel matrix for the ﬁrst coordinate of the mixture data. These are
200
viewed as estimates ˆφℓ of the eigenfunctions in (5.45), and are represented as
functions in IR1 with the observed values superimposed in color. They are arranged
ˆφℓ of
in rows, starting at the top left. (Right panel) Rescaled versions hℓ = √ˆγℓ
the functions in the left panel, for which the kernel computes the “inner product.”

l

e
u
a
v
n
e
g
E

i

1
0
+
e
1

3
0
−
e
1

7
0
−
e
1

1
1
−
e
1

5
1
−
e
1

0

10

20

30

40

50

FIGURE 5.15. The largest 50 eigenvalues of K; all those beyond the 30th are
eﬀectively zero.

174

5. Basis Expansions and Regularization

ing feature space representation of the eigenfunctions

hℓ(x) =

ˆφℓ(x), ℓ = 1, . . . , N.

ˆγℓ

(5.65)

p

i

h

h(xi), h(xi′ )

= K(xi, xi′ ). The scaling by the eigenvalues quickly
Note that
shrinks most of the functions down to zero, leaving an eﬀective dimension
of about 12 in this case. The corresponding optimization problem is a stan-
dard ridge regression, as in (5.63). So although in principle the implicit
feature space is inﬁnite dimensional, the eﬀective dimension is dramat-
ically lower because of the relative amounts of shrinkage applied to each
basis function. The kernel scale parameter ν plays a role here as well; larger
ν implies more local km functions, and increases the eﬀective dimension of
the feature space. See Hastie and Zhu (2006) for more details.

It is also known (Girosi et al., 1995) that a thin-plate spline (Section 5.7)

is an expansion in radial basis functions, generated by the kernel

K(x, y) =

x
k

−

y

2 log(
k

x
k

y

).
k

−

(5.66)

Radial basis functions are discussed in more detail in Section 6.7.

Support Vector Classiﬁers

The support vector machines of Chapter 12 for a two-class classiﬁcation
N
problem have the form f (x) = α0 +
i=1 αiK(x, xi), where the parameters
are chosen to minimize

P

min
α0,α (

N

i=1
X

[1

−

yif (xi)]+ +

λ
2

αT Kα

,

)

(5.67)

, and [z]+ denotes the positive part of z. This can be
1, 1
where yi ∈ {−
}
viewed as a quadratic optimization problem with linear constraints, and
requires a quadratic programming algorithm for its solution. The name
support vector arises from the fact that typically many of the ˆαi = 0 [due
to the piecewise-zero nature of the loss function in (5.67)], and so ˆf is an
, xi). See Section 12.3.3 for more details.
expansion in a subset of the K(

·

5.9 Wavelet Smoothing

We have seen two diﬀerent modes of operation with dictionaries of basis
functions. With regression splines, we select a subset of the bases, using
either subject-matter knowledge, or else automatically. The more adaptive
procedures such as MARS (Chapter 9) can capture both smooth and non-
smooth behavior. With smoothing splines, we use a complete basis, but
then shrink the coeﬃcients toward smoothness.

Haar Wavelets

Symmlet-8 Wavelets

5.9 Wavelet Smoothing

175

ψ6,35

ψ6,15

ψ5,15

ψ5,1

ψ4,9

ψ4,4

ψ3,5

ψ3,2

ψ2,3

ψ2,1

ψ1,0

0.0

0.2

0.4

0.6

0.8

1.0

0.0

0.2

0.4

0.6

0.8

1.0

Time

Time

FIGURE 5.16. Some selected wavelets at diﬀerent translations and dilations
for the Haar and symmlet families. The functions have been scaled to suit the
display.

Wavelets typically use a complete orthonormal basis to represent func-
tions, but then shrink and select the coeﬃcients toward a sparse represen-
tation. Just as a smooth function can be represented by a few spline basis
functions, a mostly ﬂat function with a few isolated bumps can be repre-
sented with a few (bumpy) basis functions. Wavelets bases are very popular
in signal processing and compression, since they are able to represent both
smooth and/or locally bumpy functions in an eﬃcient way—a phenomenon
dubbed time and frequency localization. In contrast, the traditional Fourier
basis allows only frequency localization.

Before we give details, let’s look at the Haar wavelets in the left panel
of Figure 5.16 to get an intuitive idea of how wavelet smoothing works.
The vertical axis indicates the scale (frequency) of the wavelets, from low
scale at the bottom to high scale at the top. At each scale the wavelets are
“packed in” side-by-side to completely ﬁll the time axis: we have only shown

176

5. Basis Expansions and Regularization

a selected subset. Wavelet smoothing ﬁts the coeﬃcients for this basis by
least squares, and then thresholds (discards, ﬁlters) the smaller coeﬃcients.
Since there are many basis functions at each scale, it can use bases where
it needs them and discard the ones it does not need, to achieve time and
frequency localization. The Haar wavelets are simple to understand, but not
smooth enough for most purposes. The symmlet wavelets in the right panel
of Figure 5.16 have the same orthonormal properties, but are smoother.

Figure 5.17 displays an NMR (nuclear magnetic resonance) signal, which
appears to be composed of smooth components and isolated spikes, plus
some noise. The wavelet transform, using a symmlet basis, is shown in the
lower left panel. The wavelet coeﬃcients are arranged in rows, from lowest
scale at the bottom, to highest scale at the top. The length of each line
segment indicates the size of the coeﬃcient. The bottom right panel shows
the wavelet coeﬃcients after they have been thresholded. The threshold
procedure, given below in equation (5.69), is the same soft-thresholding
rule that arises in the lasso procedure for linear regression (Section 3.4.2).
Notice that many of the smaller coeﬃcients have been set to zero. The
green curve in the top panel shows the back-transform of the thresholded
coeﬃcients: this is the smoothed version of the original signal. In the next
section we give the details of this process, including the construction of
wavelets and the thresholding rule.

5.9.1 Wavelet Bases and the Wavelet Transform

In this section we give details on the construction and ﬁltering of wavelets.
Wavelet bases are generated by translations and dilations of a single scal-
ing function φ(x) (also known as the father). The red curves in Figure 5.18
are the Haar and symmlet-8 scaling functions. The Haar basis is particu-
larly easy to understand, especially for anyone with experience in analysis
of variance or trees, since it produces a piecewise-constant representation.
Thus if φ(x) = I(x
k), k an integer, generates
−
an orthonormal basis for functions with jumps at the integers. Call this ref-
erence space V0. The dilations φ1,k(x) = √2φ(2x
k) form an orthonormal
−
V0 of functions piecewise constant on intervals of
basis for a space V1 ⊃
length 1
where
V1 ⊃
2 . In fact, more generally we have
each Vj is spanned by φj,k = 2j/2φ(2jx

[0, 1]), then φ0,k(x) = φ(x

V−1 ⊃ · · ·

· · · ⊃
k).

V0 ⊃

∈

Now to the deﬁnition of wavelets. In analysis of variance, we often rep-
resent a pair of means µ1 and µ2 by their grand mean µ = 1
2 (µ1 + µ2), and
then a contrast α = 1
µ2). A simpliﬁcation occurs if the contrast α is
very small, because then we can set it to zero. In a similar manner we might
represent a function in Vj+1 by a component in Vj plus the component in
Wj.
the orthogonal complement Wj of Vj to Vj+1, written as Vj+1 = Vj ⊕
The component in Wj represents detail, and we might wish to set some ele-
k)
ments of this component to zero. It is easy to see that the functions ψ(x

2 (µ1 −

−

−

5.9 Wavelet Smoothing

177

NMR Signal

0
6

0
4

0
2

0

0

200

400

600

800

1000

Wavelet Transform - Original Signal

Wavelet Transform - WaveShrunk Signal

Signal

Signal

W9

W8

W7

W6

W5

W4

V4

W9

W8

W7

W6

W5

W4

V4

0

200

400

600

800

1000

0

200

400

600

800

1000

FIGURE 5.17. The top panel shows an NMR signal, with the wavelet-shrunk
version superimposed in green. The lower left panel represents the wavelet trans-
form of the original signal, down to V4, using the symmlet-8 basis. Each coeﬃ-
cient is represented by the height (positive or negative) of the vertical bar. The
lower right panel represents the wavelet coeﬃcients after being shrunken using
the waveshrink function in S-PLUS, which implements the SureShrink method
of wavelet adaptation of Donoho and Johnstone.

178

5. Basis Expansions and Regularization

Haar Basis

Symmlet Basis

φ(x)

φ(x)

ψ(x)

ψ(x)

FIGURE 5.18. The Haar and symmlet father (scaling) wavelet φ(x) and mother
wavelet ψ(x).

generated by the mother wavelet ψ(x) = φ(2x)
mal basis for W0 for the Haar family. Likewise ψj,k = 2j/2ψ(2jx
a basis for Wj.

1) form an orthonor-
k) form

φ(2x

−

−

−

Wj = Vj−1 ⊕

Wj, so besides representing a
Now Vj+1 = Vj ⊕
function by its level-j detail and level-j rough components, the latter can
1) detail and rough, and so on. Finally we get
be broken down to level-(j
WJ−1. Figure 5.16
W1 · · · ⊕
W0 ⊕
a representation of the form VJ = V0 ⊕
on page 175 shows particular wavelets ψj,k(x).

Wj−1 ⊕

−

Notice that since these spaces are orthogonal, all the basis functions are
orthonormal. In fact, if the domain is discrete with N = 2J (time) points,
this is as far as we can go. There are 2j basis elements at level j, and
adding up, we have a total of 2J
1 elements in the Wj, and one in V0.
This structured orthonormal basis allows for a multiresolution analysis,
which we illustrate in the next section.

−

While helpful for understanding the construction above, the Haar basis
is often too coarse for practical purposes. Fortunately, many clever wavelet
bases have been invented. Figures 5.16 and 5.18 include the Daubechies
symmlet-8 basis. This basis has smoother elements than the corresponding
Haar basis, but there is a tradeoﬀ:

•

Each wavelet has a support covering 15 consecutive time intervals,
rather than one for the Haar basis. More generally, the symmlet-p
1 consecutive intervals. The wider the
family has a support of 2p
support, the more time the wavelet has to die to zero, and so it can

−

5.9 Wavelet Smoothing

179

achieve this more smoothly. Note that the eﬀective support seems to
be much narrower.

The symmlet-p wavelet ψ(x) has p vanishing moments; that is,

•

ψ(x)xjdx = 0, j = 0, . . . , p

1.

−

Z

One implication is that any order-p polynomial over the N = 2J times
points is reproduced exactly in V0 (Exercise 5.18). In this sense V0
is equivalent to the null space of the smoothing-spline penalty. The
Haar wavelets have one vanishing moment, and V0 can reproduce any
constant function.

The symmlet-p scaling functions are one of many families of wavelet

generators. The operations are similar to those for the Haar basis:

•

•

If V0 is spanned by φ(x
√2φ(2x
k) and φ(x) =
h(k).

−

P
W0 is spanned by ψ(x) =
1)1−kh(1
g(k) = (

k).

−

−

−

k), then V1 ⊃
V0 is spanned by φ1,k(x) =
k∈Z h(k)φ1,k(x), for some ﬁlter coeﬃcients

k∈Z g(k)φ1,k(x), with ﬁlter coeﬃcients

P

5.9.2 Adaptive Wavelet Filtering

Wavelets are particularly useful when the data are measured on a uniform
lattice, such as a discretized signal, image, or a time series. We will focus on
the one-dimensional case, and having N = 2J lattice-points is convenient.
Suppose y is the response vector, and W is the N
N orthonormal wavelet
basis matrix evaluated at the N uniformly spaced observations. Then y∗ =
WT y is called the wavelet transform of y (and is the full least squares
regression coeﬃcient). A popular method for adaptive wavelet ﬁtting is
known as SURE shrinkage (Stein Unbiased Risk Estimation, Donoho and
Johnstone (1994)). We start with the criterion

×

y

min

θ ||

−

Wθ

||

2
2 + 2λ

θ

||1,

||

(5.68)

which is the same as the lasso criterion in Chapter 3. Because W is or-
thonormal, this leads to the simple solution:

ˆθj = sign(y∗

j )(

y∗
j | −

λ)+.

|
The least squares coeﬃcients are translated toward zero, and truncated
at zero. The ﬁtted function (vector) is then given by the inverse wavelet
transform ˆf = Wˆθ.

(5.69)

180

5. Basis Expansions and Regularization

A simple choice for λ is λ = σ√2 log N , where σ is an estimate of the
standard deviation of the noise. We can give some motivation for this choice.
Since W is an orthonormal transformation, if the elements of y are white
noise (independent Gaussian variates with mean 0 and variance σ2), then
so are y∗. Furthermore if random variables Z1, Z2, . . . , ZN are white noise,
, j = 1, . . . , N is approximately σ√2 log N .
the expected maximum of
Hence all coeﬃcients below σ√2 log N are likely to be noise and are set to
zero.

Zj|

|

The space W could be any basis of orthonormal functions: polynomials,
natural splines or cosinusoids. What makes wavelets special is the particular
form of basis functions used, which allows for a representation localized in
time and in frequency.

−

Let’s look again at the NMR signal of Figure 5.17. The wavelet transform
8 basis. Notice that the coeﬃcients do not
was computed using a symmlet
descend all the way to V0, but stop at V4 which has 16 basis functions.
As we ascend to each level of detail, the coeﬃcients get smaller, except in
locations where spiky behavior is present. The wavelet coeﬃcients represent
characteristics of the signal localized in time (the basis functions at each
level are translations of each other) and localized in frequency. Each dilation
increases the detail by a factor of two, and in this sense corresponds to
doubling the frequency in a traditional Fourier representation. In fact, a
more mathematical understanding of wavelets reveals that the wavelets at
a particular scale have a Fourier transform that is restricted to a limited
range or octave of frequencies.

×

The shrinking/truncation in the right panel was achieved using the SURE
approach described in the introduction to this section. The orthonormal
N basis matrix W has columns which are the wavelet basis functions
N
evaluated at the N time points. In particular, in this case there will be 16
columns corresponding to the φ4,k(x), and the remainder devoted to the
ψj,k(x), j = 4, . . . , 11. In practice λ depends on the noise variance, and has
to be estimated from the data (such as the variance of the coeﬃcients at
the highest level).

Notice the similarity between the SURE criterion (5.68) on page 179,

and the smoothing spline criterion (5.21) on page 156:

•

•

Both are hierarchically structured from coarse to ﬁne detail, although
wavelets are also localized in time within each resolution level.

The splines build in a bias toward smooth functions by imposing
diﬀerential shrinking constants dk. Early versions of SURE shrinkage
treated all scales equally. The S+wavelets function waveshrink() has
many options, some of which allow for diﬀerential shrinkage.

•

The spline L2 penalty cause pure shrinkage, while the SURE L1
penalty does shrinkage and selection.

Exercises

181

More generally smoothing splines achieve compression of the original signal
by imposing smoothness, while wavelets impose sparsity. Figure 5.19 com-
pares a wavelet ﬁt (using SURE shrinkage) to a smoothing spline ﬁt (using
cross-validation) on two examples diﬀerent in nature. For the NMR data in
the upper panel, the smoothing spline introduces detail everywhere in order
to capture the detail in the isolated spikes; the wavelet ﬁt nicely localizes
the spikes. In the lower panel, the true function is smooth, and the noise is
relatively high. The wavelet ﬁt has let in some additional and unnecessary
wiggles—a price it pays in variance for the additional adaptivity.

The wavelet transform is not performed by matrix multiplication as in
y∗ = WT y. In fact, using clever pyramidal schemes y∗ can be obtained
in O(N ) computations, which is even faster than the N log(N ) of the fast
Fourier transform (FFT). While the general construction is beyond the
scope of this book, it is easy to see for the Haar basis (Exercise 5.19).
Likewise, the inverse wavelet transform Wˆθ is also O(N ).

This has been a very brief glimpse of this vast and growing ﬁeld. There is
a very large mathematical and computational base built on wavelets. Mod-
ern image compression is often performed using two-dimensional wavelet
representations.

Bibliographic Notes

Splines and B-splines are discussed in detail in de Boor (1978). Green
and Silverman (1994) and Wahba (1990) give a thorough treatment of
smoothing splines and thin-plate splines; the latter also covers reproducing
kernel Hilbert spaces. See also Girosi et al. (1995) and Evgeniou et al.
(2000) for connections between many nonparametric regression techniques
using RKHS approaches. Modeling functional data, as in Section 5.2.3, is
covered in detail in Ramsay and Silverman (1997).

Daubechies (1992) is a classic and mathematical treatment of wavelets.
Other useful sources are Chui (1992) and Wickerhauser (1994). Donoho and
Johnstone (1994) developed the SURE shrinkage and selection technology
from a statistical estimation framework; see also Vidakovic (1999). Bruce
and Gao (1996) is a useful applied introduction, which also describes the
wavelet software in S-PLUS.

Exercises

Ex. 5.1 Show that the truncated power basis functions in (5.3) represent a
basis for a cubic spline with the two knots as indicated.

182

5. Basis Expansions and Regularization

0
6

0
4

0
2

0

4

2

n

0

2
-

4
-

spline
wavelet

0

200

400

600

800

1000

NMR Signal

•

•

••
•

•

•
•

•
•

•

••
•
••

•
••

•
•
••
••••
•

•

••

•

•

•
•
•

•

•

•
•
•

•

••
•

•
•

•
•
•

••

•
•

•
•
•

•
••

•
••
•

•

•
•
••
•

••
•

•
•

•

spline
wavelet
true

•

•

•

•

•

•

•
••

•
•••

•

•

•

•

•
•
•

•

•
•
•
•
•

•

•
•
•
••••

•
•
••

•
•

•
•
•
•
•

•

•

•

•
•

•

•

0.2

0.0

0.4

0.6

0.8

1.0

Smooth Function (Simulated)

FIGURE 5.19. Wavelet smoothing compared with smoothing splines on two
examples. Each panel compares the SURE-shrunk wavelet ﬁt to the cross-validated
smoothing spline ﬁt.

Ex. 5.2 Suppose that Bi,M (x) is an order-M B-spline deﬁned in the Ap-
pendix on page 186 through the sequence (5.77)–(5.78).

Exercises

183

(a) Show by induction that Bi,M (x) = 0 for x

[τi, τi+M ]. This shows, for

example, that the support of cubic B-splines is at most 5 knots.

6∈

(b) Show by induction that Bi,M (x) > 0 for x

∈
are positive in the interior of their support.

(τi, τi+M ). The B-splines

(c) Show by induction that

K+M
i=1 Bi,M (x) = 1

x

∀

∈

[ξ0, ξK+1].

(d) Show that Bi,M is a piecewise polynomial of order M (degree M

P

on [ξ0, ξK+1], with breaks only at the knots ξ1, . . . , ξK .

1)

−

(e) Show that an order-M B-spline basis function is the density function

of a convolution of M uniform random variables.

Ex. 5.3 Write a program to reproduce Figure 5.3 on page 145.

Ex. 5.4 Consider the truncated power series representation for cubic splines
with K interior knots. Let

f (X) =

βjX j +

3

j=0
X

K

Xk=1

θk(X

ξk)3
+.

−

(5.70)

Prove that the natural boundary conditions for natural cubic splines (Sec-
tion 5.2.1) imply the following linear constraints on the coeﬃcients:

K
k=1 θk = 0,
K
k=1 ξkθk = 0.
P
P
Hence derive the basis (5.4) and (5.5).

β2 = 0,
β3 = 0,

(5.71)

Ex. 5.5 Write a program to classify the phoneme data using a quadratic dis-
criminant analysis (Section 4.3). Since there are many correlated features,
you should ﬁlter them using a smooth basis of natural cubic splines (Sec-
tion 5.2.3). Decide beforehand on a series of ﬁve diﬀerent choices for the
number and position of the knots, and use tenfold cross-validation to make
the ﬁnal selection. The phoneme data are available from the book website
www-stat.stanford.edu/ElemStatLearn.

Ex. 5.6 Suppose you wish to ﬁt a periodic function, with a known period T .
Describe how you could modify the truncated power series basis to achieve
this goal.

Ex. 5.7 Derivation of smoothing splines (Green and Silverman, 1994). Sup-
pose that N
2, and that g is the natural cubic spline interpolant to the
≥
N
< xN < b. This is a natural spline
1 , with a < x1 <
xi, zi}
pairs
{

· · ·

184

5. Basis Expansions and Regularization

with a knot at every xi; being an N -dimensional space of functions, we can
determine the coeﬃcients such that it interpolates the sequence zi exactly.
Let ˜g be any other diﬀerentiable function on [a, b] that interpolates the N
pairs.

(a) Let h(x) = ˜g(x)

g(x). Use integration by parts and the fact that g is

a natural cubic spline to show that

−

b

a

Z

g′′(x)h′′(x)dx =

−

= 0.

N −1

j=1
X

g′′′(x+
j )

h(xj+1)
{

−

h(xj)

}

(5.72)

(b) Hence show that

b

a

˜g′′(t)2dt

≥

b

a

g′′(t)2dt,

Z

Z

and that equality can only hold if h is identically zero in [a, b].

(c) Consider the penalized least squares problem

min

f "

N

i=1
X

(yi −

f (xi))2 + λ

f ′′(t)2dt

b

a

Z

.

#

Use (b) to argue that the minimizer must be a cubic spline with knots
at each of the xi.

Ex. 5.8 In the appendix to this chapter we show how the smoothing spline
computations could be more eﬃciently carried out using a (N + 4) dimen-
sional basis of B-splines. Describe a slightly simpler scheme using a (N + 2)
dimensional B-spline basis deﬁned on the N

2 interior knots.

−

Ex. 5.9 Derive the Reinsch form Sλ = (I + λK)−1 for the smoothing spline.

Ex. 5.10 Derive an expression for Var( ˆfλ(x0)) and bias( ˆfλ(x0)). Using the
example (5.22), create a version of Figure 5.9 where the mean and several
(pointwise) quantiles of ˆfλ(x) are shown.

Ex. 5.11 Prove that for a smoothing spline the null space of K is spanned
by functions linear in X.

Ex. 5.12 Characterize the solution to the following problem,

min
f

RSS(f, λ) =

N

i=1
X

wi{

yi −

f (xi)

2 + λ
}

f ′′(t)
{

2dt,
}

Z

(5.73)

0 are observation weights.

where the wi ≥
the training data have ties in X.

Characterize the solution to the smoothing spline problem (5.9) when

Exercises

185

Ex. 5.13 You have ﬁtted a smoothing spline ˆfλ to a sample of N pairs
(xi, yi). Suppose you augment your original sample with the pair x0, ˆfλ(x0),
and reﬁt; describe the result. Use this to derive the N -fold cross-validation
formula (5.26).

Ex. 5.14 Derive the constraints on the αj in the thin-plate spline expan-
sion (5.39) to guarantee that the penalty J(f ) is ﬁnite. How else could one
ensure that the penalty was ﬁnite?

Ex. 5.15 This exercise derives some of the results quoted in Section 5.8.1.
∈ HK. Show
Suppose K(x, y) satisfying the conditions (5.45) and let f (x)
that

, xi), f

iHK = f (xi).

(a)

(b)

K(

·
K(

·

h

h

, xi), K(

, xj)

iHK = K(xi, xj).

·
N
i=1 αiK(x, xi), then

(c) If g(x) =

P

N

N

J(g) =

K(xi, xj)αiαj.

i=1
X

j=1
X

Suppose that ˜g(x) = g(x) + ρ(x), with ρ(x)
to each of K(x, xi), i = 1, . . . , N . Show that

∈ HK, and orthogonal in

HK

(d)

N

L(yi, ˜g(xi)) + λJ(˜g)

i=1
X
with equality iﬀ ρ(x) = 0.

N

≥

i=1
X

L(yi, g(xi)) + λJ(g)

(5.74)

N .
Ex. 5.16 Consider the ridge regression problem (5.53), and assume M
Assume you have a kernel K that computes the inner product K(x, y) =

≥

M
m=1 hm(x)hm(y).

P

(a) Derive (5.62) on page 171 in the text. How would you compute the
matrices V and Dγ, given K? Hence show that (5.63) is equivalent
to (5.53).

(b) Show that

ˆf = Hˆβ

= K(K + λI)−1y,

(5.75)

where H is the N
the N

×

×

M matrix of evaluations hm(xi), and K = HHT

N matrix of inner-products h(xi)T h(xj).

186

5. Basis Expansions and Regularization

(c) Show that

ˆf (x) = h(x)T ˆβ

N

=

K(x, xi) ˆαi

i=1
X

(5.76)

and ˆα = (K + λI)−1y.

(d) How would you modify your solution if M < N ?

Ex. 5.17 Show how to convert the discrete eigen-decomposition of K in
Section 5.8.2 to estimates of the eigenfunctions of K.

Ex. 5.18 The wavelet function ψ(x) of the symmlet-p wavelet basis has
vanishing moments up to order p. Show that this implies that polynomials
of order p are represented exactly in V0, deﬁned on page 176.

Ex. 5.19 Show that the Haar wavelet transform of a signal of length N = 2J
can be computed in O(N ) computations.

Appendix: Computations for Splines

In this Appendix, we describe the B-spline basis for representing polyno-
mial splines. We also discuss their use in the computations of smoothing
splines.

B-splines

Before we can get started, we need to augment the knot sequence deﬁned
in Section 5.2. Let ξ0 < ξ1 and ξK < ξK+1 be two boundary knots, which
typically deﬁne the domain over which we wish to evaluate our spline. We
now deﬁne the augmented knot sequence τ such that

τ2 ≤ · · · ≤
τ1 ≤
τj+M = ξj, j = 1,

τM ≤

ξ0;

, K;

· · ·
τK+M +2 ≤ · · · ≤
τK+M +1 ≤

ξK+1 ≤

•

•

•

τK+2M .

The actual values of these additional knots beyond the boundary are arbi-
trary, and it is customary to make them all the same and equal to ξ0 and
ξK+1, respectively.

Denote by Bi,m(x) the ith B-spline basis function of order m for the
M . They are deﬁned recursively in terms of divided

knot-sequence τ , m

≤

diﬀerences as follows:

Bi,1(x) =

1
0
for i = 1, . . . , K + 2M

(cid:26)

Appendix: Computations for Splines

187

x < τi+1

if τi ≤
otherwise

(5.77)

1. These are also known as Haar basis functions.

−

Bi,m(x) =

for i = 1, . . . , K + 2M

x
τi
−
τi+m−1 −
m.
−

τi

Bi,m−1(x) +

τi+m −
τi+m −

x
τi+1

Bi+1,m−1(x)

(5.78)

· · ·

Thus with M = 4, Bi,4, i = 1,
, K + 4 are the K + 4 cubic B-spline
basis functions for the knot sequence ξ. This recursion can be contin-
ued and will generate the B-spline basis for any order spline. Figure 5.20
shows the sequence of B-splines up to order four with knots at the points
0.0, 0.1, . . . , 1.0. Since we have created some duplicate knots, some care
has to be taken to avoid division by zero. If we adopt the convention
that Bi,1 = 0 if τi = τi+1, then by induction Bi,m = 0 if τi = τi+1 =
. . . = τi+m. Note also that in the construction above, only the subset
Bi,m,
m + 1, . . . , M + K are required for the B-spline basis
−
of order m < M with knots ξ.

i = M

To fully understand the properties of these functions, and to show that
they do indeed span the space of cubic splines for the knot sequence, re-
quires additional mathematical machinery, including the properties of di-
vided diﬀerences. Exercise 5.2 explores these issues.

≤

rj ≤

The scope of B-splines is in fact bigger than advertised here, and has to
do with knot duplication. If we duplicate an interior knot in the construc-
tion of the τ sequence above, and then generate the B-spline sequence as
before, the resulting basis spans the space of piecewise polynomials with
one less continuous derivative at the duplicated knot. In general, if in ad-
dition to the repeated boundary knots, we include the interior knot ξj
M times, then the lowest-order derivative to be discontinuous
1
rj. Thus for cubic splines with no repeats,
at x = ξj will be order M
rj = 1, j = 1, . . . , K, and at each interior knot the third derivatives (4
1)
are discontinuous. Repeating the jth knot three times leads to a discontin-
uous 1st derivative; repeating it four times leads to a discontinuous zeroth
derivative, i.e., the function is discontinuous at x = ξj. This is exactly what
happens at the boundary knots; we repeat the knots M times, so the spline
becomes discontinuous at the boundary knots (i.e., undeﬁned beyond the
boundary).

−

−

The local support of B-splines has important computational implica-
tions, especially when the number of knots K is large. Least squares com-
putations with N observations and K + M variables (basis functions) take
O(N (K + M )2 + (K + M )3) ﬂops (ﬂoating point operations.) If K is some
appreciable fraction of N , this leads to O(N 3) algorithms which becomes

188

5. Basis Expansions and Regularization

B-splines of Order 1

2
1

.

8
0

.

4
0

.

0
0

.

2
.
1

8
.
0

4
.
0

0
.
0

2
.
1

8
.
0

4
.
0

0
.
0

2
.
1

8
.
0

4
.
0

0
.
0

0.0

0.2

0.4

0.6

0.8

1.0

B-splines of Order 2

0.0

0.2

0.4

0.6

0.8

1.0

B-splines of Order 3

0.0

0.2

0.4

0.6

0.8

1.0

B-splines of Order 4

0.0

0.2

0.4

0.6

0.8

1.0

FIGURE 5.20. The sequence of B-splines up to order four with ten knots evenly
spaced from 0 to 1. The B-splines have local support; they are nonzero on an
interval spanned by M + 1 knots.

Appendix: Computations for Splines

189

unacceptable for large N . If the N observations are sorted, the N
(K +M )
regression matrix consisting of the K + M B-spline basis functions evalu-
ated at the N points has many zeros, which can be exploited to reduce the
computational complexity back to O(N ). We take this up further in the
next section.

×

Computations for Smoothing Splines

Although natural splines (Section 5.2.1) provide a basis for smoothing
splines, it is computationally more convenient to operate in the larger space
of unconstrained B-splines. We write f (x) =
γjBj(x), where γj are
coeﬃcients and the Bj are the cubic B-spline basis functions. The solution
looks the same as before,

N +4
1

P

ˆγ = (BT B + λΩB)−1BT y,

(5.79)

×

×

N matrix N is replaced by the N

except now the N
(N + 4) matrix
B, and similarly the (N + 4)
(N + 4) penalty matrix ΩB replaces the
N dimensional ΩN . Although at face value it seems that there are
N
no boundary derivative constraints, it turns out that the penalty term
automatically imposes them by giving eﬀectively inﬁnite weight to any non
zero derivative beyond the boundary. In practice, ˆγ is restricted to a linear
subspace for which the penalty is always ﬁnite.

×

×

Since the columns of B are the evaluated B-splines, in order from left
to right and evaluated at the sorted values of X, and the cubic B-splines
have local support, B is lower 4-banded. Consequently the matrix M =
(BTB + λΩ) is 4-banded and hence its Cholesky decomposition M = LLT
can be computed easily. One then solves LLT γ = BT y by back-substitution
to give γ and hence the solution ˆf in O(N ) operations.

In practice, when N is large, it is unnecessary to use all N interior knots,
and any reasonable thinning strategy will save in computations and have
negligible eﬀect on the ﬁt. For example, the smooth.spline function in S-
PLUS uses an approximately logarithmic strategy: if N < 50 all knots are
included, but even at N = 5, 000 only 204 knots are used.

190

5. Basis Expansions and Regularization

6
Kernel Smoothing Methods

This is page 191
Printer: Opaque this

In this chapter we describe a class of regression techniques that achieve
ﬂexibility in estimating the regression function f (X) over the domain IRp
by ﬁtting a diﬀerent but simple model separately at each query point x0.
This is done by using only those observations close to the target point x0 to
ﬁt the simple model, and in such a way that the resulting estimated function
ˆf (X) is smooth in IRp. This localization is achieved via a weighting function
or kernel Kλ(x0, xi), which assigns a weight to xi based on its distance from
x0. The kernels Kλ are typically indexed by a parameter λ that dictates
the width of the neighborhood. These memory-based methods require in
principle little or no training; all the work gets done at evaluation time.
The only parameter that needs to be determined from the training data is
λ. The model, however, is the entire training data set.

We also discuss more general classes of kernel-based techniques , which
tie in with structured methods in other chapters, and are useful for density
estimation and classiﬁcation.

The techniques in this chapter should not be confused with those asso-
ciated with the more recent usage of the phrase “kernel methods”. In this
chapter kernels are mostly used as a device for localization. We discuss ker-
nel methods in Sections 5.8, 14.5.4, 18.5 and Chapter 12; in those contexts
the kernel computes an inner product in a high-dimensional (implicit) fea-
ture space, and is used for regularized nonlinear modeling. We make some
connections to the methodology in this chapter at the end of Section 6.7.

192

6. Kernel Smoothing Methods

Nearest-Neighbor Kernel

Epanechnikov Kernel

O

O
O
O

O
O
O
O
O

O
O

O
O
O
O

O
O

O
O

O
O
O
O

O
O

O

O
O

O
O

O
O

O

O
O
O

O
O
O
O
O
O

ˆf (x0)
O
O
•
OO
OO
OO
OO

O
O
O
O

O
O

O
O

O
O
O O
O

O

O
O

O
O
O
O

O
O

O
O

O
O

O
O

OO

O

OO

O
O

O
O

O
O

OO

O
O

O

O

O

O

OOO

O

O

O

O

O

O
O

OO
O
O

OO
O

O

O

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

O

O

O

O

OOO

O

O

O

O

O

O
O

OO
O
O

OO
O

O

O

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

O

O

O

O

O

O
O

O

O

O

O

O

O

O

O

O

O

O
O
O

O
O
O
O
O
O
O
O
O
O

O
O

O
O
O
O

O
O

O
O

O
O
O
O

O
O

O
O

O
O

O
O

O
O

O
O

O
O
O

O
O
O
O
O
O

ˆf (x0)
O
O
•
OO
OO
OO
OO

O
O
O
O

O
O

O
O

O
O
O O
O O

O
O

O
O

O
O
O
O

O
O

O
O

O
O

O
O

OO
OO

O

OO

O
O

O
O

O
O

OO

O
O

O

O

O

O

O

O
O

O

O

O

O

O

O

O

O

O

0.0

0.2

0.4

x0

0.6

0.8

1.0

0.0

0.2

0.4

x0

0.6

0.8

1.0

FIGURE 6.1. In each panel 100 pairs xi, yi are generated at random from the
N (0, 1/3). In
blue curve with Gaussian errors: Y = sin(4X) + ε, X
the left panel the green curve is the result of a 30-nearest-neighbor running-mean
smoother. The red point is the ﬁtted constant ˆf (x0), and the red circles indicate
those observations contributing to the ﬁt at x0. The solid yellow region indicates
the weights assigned to observations. In the right panel, the green curve is the
kernel-weighted average, using an Epanechnikov kernel with (half ) window width
λ = 0.2.

U [0, 1], ε

∼

∼

6.1 One-Dimensional Kernel Smoothers

|

(6.1)

Nk(x))

In Chapter 2, we motivated the k–nearest-neighbor average
ˆf (x) = Ave(yi|

xi ∈
as an estimate of the regression function E(Y
X = x). Here Nk(x) is the set
of k points nearest to x in squared distance, and Ave denotes the average
(mean). The idea is to relax the deﬁnition of conditional expectation, as
illustrated in the left panel of Figure 6.1, and compute an average in a
neighborhood of the target point. In this case we have used the 30-nearest
neighborhood—the ﬁt at x0 is the average of the 30 pairs whose xi values
are closest to x0. The green curve is traced out as we apply this deﬁnition
at diﬀerent values x0. The green curve is bumpy, since ˆf (x) is discontinuous
in x. As we move x0 from left to right, the k-nearest neighborhood remains
constant, until a point xi to the right of x0 becomes closer than the furthest
point xi′ in the neighborhood to the left of x0, at which time xi replaces xi′.
The average in (6.1) changes in a discrete way, leading to a discontinuous
ˆf (x).

This discontinuity is ugly and unnecessary. Rather than give all the
points in the neighborhood equal weight, we can assign weights that die
oﬀ smoothly with distance from the target point. The right panel shows
an example of this, using the so-called Nadaraya–Watson kernel-weighted

6.1 One-Dimensional Kernel Smoothers

193

average

ˆf (x0) =

N
i=1 Kλ(x0, xi)yi
N
i=1 Kλ(x0, xi)

,

P

with the Epanechnikov quadratic kernel

P

Kλ(x0, x) = D

x

|

x0|

−
λ

,

(cid:19)

t

if
1;
| ≤
otherwise.

|

(cid:18)

t2)

3
4 (1
0

−

(cid:26)

with

D(t) =

(6.2)

(6.3)

(6.4)

The ﬁtted function is now continuous, and quite smooth in the right panel
of Figure 6.1. As we move the target from left to right, points enter the
neighborhood initially with weight zero, and then their contribution slowly
increases (see Exercise 6.1).

In the right panel we used a metric window size λ = 0.2 for the kernel
ﬁt, which does not change as we move the target point x0, while the size
of the 30-nearest-neighbor smoothing window adapts to the local density
of the xi. One can, however, also use such adaptive neighborhoods with
kernels, but we need to use a more general notation. Let hλ(x0) be a width
function (indexed by λ) that determines the width of the neighborhood at
x0. Then more generally we have

Kλ(x0, x) = D

x0|
x
|
−
hλ(x0)

.

(cid:19)

(cid:18)

(6.5)

In (6.3), hλ(x0) = λ is constant. For k-nearest neighborhoods, the neigh-
where x[k] is
borhood size k replaces λ, and we have hk(x0) =
the kth closest xi to x0.

x0 −

x[k]|

|

There are a number of details that one has to attend to in practice:

•

•

•

The smoothing parameter λ, which determines the width of the local
neighborhood, has to be determined. Large λ implies lower variance
(averages over more observations) but higher bias (we essentially as-
sume the true function is constant within the window).

Metric window widths (constant hλ(x)) tend to keep the bias of the
estimate constant, but the variance is inversely proportional to the
local density. Nearest-neighbor window widths exhibit the opposite
behavior; the variance stays constant and the absolute bias varies
inversely with local density.

Issues arise with nearest-neighbors when there are ties in the xi. With
most smoothing techniques one can simply reduce the data set by
averaging the yi at tied values of X, and supplementing these new
observations at the unique values of xi with an additional weight wi
(which multiples the kernel weight).

194

6. Kernel Smoothing Methods

)
x
,
0
x
(
λ
K

8

.

0

4
0

.

0

.

0

Epanechnikov
Tri-cube
Gaussian

-3

-2

-1

0

1

2

3

FIGURE 6.2. A comparison of three popular kernels for local smoothing. Each
has been calibrated to integrate to 1. The tri-cube kernel is compact and has two
continuous derivatives at the boundary of its support, while the Epanechnikov ker-
nel has none. The Gaussian kernel is continuously diﬀerentiable, but has inﬁnite
support.

•

•

•

This leaves a more general problem to deal with: observation weights
wi. Operationally we simply multiply them by the kernel weights be-
fore computing the weighted average. With nearest neighborhoods, it
is now natural to insist on neighborhoods with a total weight content
k (relative to
wi). In the event of overﬂow (the last observation
needed in a neighborhood has a weight wj which causes the sum of
weights to exceed the budget k), then fractional parts can be used.

P

Boundary issues arise. The metric neighborhoods tend to contain less
points on the boundaries, while the nearest-neighborhoods get wider.

The Epanechnikov kernel has compact support (needed when used
with nearest-neighbor window size). Another popular compact kernel
is based on the tri-cube function

D(t) =

(cid:26)

3)3

t

|

− |

(1
0

t

1;
if
| ≤
otherwise

|

(6.6)

This is ﬂatter on the top (like the nearest-neighbor box) and is diﬀer-
entiable at the boundary of its support. The Gaussian density func-
tion D(t) = φ(t) is a popular noncompact kernel, with the standard-
deviation playing the role of the window size. Figure 6.2 compares
the three.

6.1.1 Local Linear Regression

We have progressed from the raw moving average to a smoothly varying
locally weighted average by using kernel weighting. The smooth kernel ﬁt
still has problems, however, as exhibited in Figure 6.3 (left panel). Locally-
weighted averages can be badly biased on the boundaries of the domain,

6.1 One-Dimensional Kernel Smoothers

195

N-W Kernel at Boundary

Local Linear Regression at Boundary

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

O
O

O

O

OO
O

O
O
OO

O

O

O
O

O

O
O
O
O
O
O

O
O

O
O

O
O

O
O

OO
OO

O
O
O
O

O
O
O
O
O
O

ˆf (x0)
•

O
O
O
O
O
O

O
O

O
O

O

O
O
O
O

OO
O

O

O

O
O

O

O

O

O

O
O

O
O

O
O

O
O
O
O
O
O

O
O

O
O
O
O
O
O

O

O

O

O

O

O O
O

O

O
O
O

O
O

O

O

O
O

O
O

O
O

O

O

O

O
O

O

O

O

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

O

O

O

O

O
O

O

O

O
O

O

O
O
O
O

OO
O

O

O

O
O

O

O

O

O

O
O

O
O

O

O

OO
O

O
O
OO

O

O

O
O

O

O
O
O
O
O
O

O
O

O
O

O
O

O
O
O
O
O
O

O
O

O
O
O
O

O
O
O
O
O
O

OO
OO

ˆf (x0)
•

O
O

O
O

O
O
O
O
O
O

O
O

O
O

O
O

O
O
O
O
O
O

O

O

O

O

O

O O
O

O

O
O
O

O
O

O

O

O
O

O
O

O
O

O

O

O

O
O

O

O

O

O

O

O

O

O
O

O

O

O
O

0.0

x0

0.2

0.4

0.6

0.8

1.0

0.0

x0

0.2

0.4

0.6

0.8

1.0

FIGURE 6.3. The locally weighted average has bias problems at or near the
boundaries of the domain. The true function is approximately linear here, but
most of the observations in the neighborhood have a higher mean than the target
point, so despite weighting, their mean will be biased upwards. By ﬁtting a locally
weighted linear regression (right panel), this bias is removed to ﬁrst order.

because of the asymmetry of the kernel in that region. By ﬁtting straight
lines rather than constants locally, we can remove this bias exactly to ﬁrst
order; see Figure 6.3 (right panel). Actually, this bias can be present in the
interior of the domain as well, if the X values are not equally spaced (for
the same reasons, but usually less severe). Again locally weighted linear
regression will make a ﬁrst-order correction.

Locally weighted regression solves a separate weighted least squares prob-

lem at each target point x0:

min
α(x0),β(x0)

N

i=1
X

Kλ(x0, xi) [yi −

α(x0)

−

β(x0)xi]2 .

(6.7)

The estimate is then ˆf (x0) = ˆα(x0) + ˆβ(x0)x0. Notice that although we ﬁt
an entire linear model to the data in the region, we only use it to evaluate
the ﬁt at the single point x0.

Deﬁne the vector-valued function b(x)T = (1, x). Let B be the N

regression matrix with ith row b(xi)T , and W(x0) the N
matrix with ith diagonal element Kλ(x0, xi). Then

×

ˆf (x0) = b(x0)T (BT W(x0)B)−1BT W(x0)y

N

=

li(x0)yi.

i=1
X

2
N diagonal

×

(6.8)

(6.9)

Equation (6.8) gives an explicit expression for the local linear regression
estimate, and (6.9) highlights the fact that the estimate is linear in the

196

6. Kernel Smoothing Methods

Local Linear Equivalent Kernel at Boundary

Local Linear Equivalent Kernel in Interior

•••••

•••

•

O

O

O

O
O

O

OO

O
O

O
O

O
O

••

O

OOO
OOO

O

OO
O
O
O

O
O

O

O

O

O

O

O

O

O

O

O

O
O

O
O

O
O

O

O
O

O

O

O

O

O
O
O
O

••
ˆf (x0)
••••
•
••••••••• ••••••••••••••••••••••••••••• • ••••••••••••••••••• •••••• • •• ••••••••••••••

O
OO
O

O
O
O
O

O
OO

O
O
O
O

O O

O
O

O

O

O

O
O

O

O

O

O
O

O

O
O

O

O
O

O

O

O

OO
O

O
O

O

O
O

O
O
O
O

O
O

O
O

O

OO
O
O
O
O
O
OO

OO

O

O

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

O
O

O
O

O
O

O

O
O
O
O

O

O

O

O

OOO

O
O

O
O
O
O

O
O

O

O

O
O

O
O

O
O

O

O

O
O

O
O

•••
•••••••••••••••••••••••••• •••

O

O

O

O

O

O

O
O

•••

O
O

OO
OO
O
O
O
O
O
O

O
O

O
O
O
O

••••••••••••

O
O

OO
OO

•••••••• • ••••
ˆf (x0)
••••
•

O
O

O
O

O
O

O
O

O
O

O
O

O
O

O
O

•
••

O
O

O
O

O
O

O
O

O
O

O
O

O
O
OO
OO
O
O

O
O
O
O

O

O

•
•
O
O

O

O

O
O

O

O
•••••• •••••• • •• ••••••••••••••
O O

O
OO

OO
O

O

OO
O
O
O
O
O
OO

OO

0.0

x0

0.2

0.4

0.6

0.8

1.0

0.0

0.2

0.4

O

O

x0

0.6

0.8

1.0

FIGURE 6.4. The green points show the equivalent kernel li(x0) for local re-
gression. These are the weights in ˆf (x0) =
N
i=1 li(x0)yi, plotted against their
corresponding xi. For display purposes, these have been rescaled, since in fact
they sum to 1. Since the yellow shaded region is the (rescaled) equivalent kernel
for the Nadaraya–Watson local average, we see how local regression automati-
cally modiﬁes the weighting kernel to correct for biases due to asymmetry in the
smoothing window.

P

·

yi (the li(x0) do not involve y). These weights li(x0) combine the weight-
ing kernel Kλ(x0,
) and the least squares operations, and are sometimes
referred to as the equivalent kernel. Figure 6.4 illustrates the eﬀect of lo-
cal linear regression on the equivalent kernel. Historically, the bias in the
Nadaraya–Watson and other local average kernel methods were corrected
by modifying the kernel. These modiﬁcations were based on theoretical
asymptotic mean-square-error considerations, and besides being tedious to
implement, are only approximate for ﬁnite sample sizes. Local linear re-
gression automatically modiﬁes the kernel to correct the bias exactly to
ﬁrst order, a phenomenon dubbed as automatic kernel carpentry. Consider
the following expansion for E ˆf (x0), using the linearity of local regression
and a series expansion of the true function f around x0,

E ˆf (x0) =

N

i=1
X

li(x0)f (xi)

N

N

= f (x0)

li(x0) + f ′(x0)

(xi −

x0)li(x0)

i=1
X
x0)2li(x0) + R,

(6.10)

i=1
X
f ′′(x0)
2

+

N

i=1
X

(xi −

where the remainder term R involves third- and higher-order derivatives of
f , and is typically small under suitable smoothness assumptions. It can be

O
O

OO
OO

O
O

O

O

OO
OO
O
O

O

O
O

O
O

O
O

O
O

Local Linear in Interior

O
O

O
O

O
O

O
O

O
O

O
O

O
O

O
O
O
O

O
O

O
O

ˆf (x0)
•

O
O
O
O
O
O

O
O
O
O

O
O

O
O
O
O
O
O
O
O

O
O

O
O

O
O

O
O

O
O

O
O

O
O

O

O
O

O
O

O

O
O
O
O
O
O
O
O

O

O
O

O
O

O
O
O
O
O

O
O

O

O

O

OO
OO

O

O

O

O

O

O

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

6.1 One-Dimensional Kernel Smoothers

197

Local Quadratic in Interior

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

O

O

O
O
O

O

OO

O

O
O

O

O

O

OO

O

O

O
O

O
O

O

O

O

O

O

O
O

OO
OO

O
O

O
O

O
O

O
O

O

O

O
O

O
O

O
O

O
O
O
O

O
O

O
O

ˆf (x0)
•

O
O
O
O

O
O
O
O
O
O

O
O

O
O
O
O
O
O
O
O

O
O

O
O

O
O

O
O

O
O

O
O

O
O

O
O

OO
OO
O
O

O

O
O

O
O

O
O

O
O

O

O

OO
OO

O

O

O

O

O

O

O

O
O

O
O

O

O
O
O
O
O
O
O
O

O

O
O

O
O

O
O
O
O
O

O
O

O

O

O

O
O
O

O

OO

O

O
O

O

O

O

OO

O

O

O
O

O
O

O

O

O

O

O

0.0

0.2

0.4

0.6

0.8

1.0

0.0

0.2

0.4

0.6

0.8

1.0

FIGURE 6.5. Local linear ﬁts exhibit bias in regions of curvature of the true
function. Local quadratic ﬁts tend to eliminate this bias.

N

shown (Exercise 6.2) that for local linear regression,

N
i=1 li(x0) = 1 and
x0)li(x0) = 0. Hence the middle term equals f (x0), and since
f (x0), we see that it depends only on quadratic and

the bias is E ˆf (x0)
P
−
higher–order terms in the expansion of f .

i=1(xi −

P

6.1.2 Local Polynomial Regression

Why stop at local linear ﬁts? We can ﬁt local polynomial ﬁts of any de-
gree d,

min
α(x0),βj (x0), j=1,...,d

N

i=1
X

Kλ(x0, xi)

yi −



α(x0)

−

2

βj(x0)xj

i 

(6.11)

d

j=1
X




ˆβj(x0)xj

d
j=1

with solution ˆf (x0) = ˆα(x0)+
0. In fact, an expansion such as
(6.10) will tell us that the bias will only have components of degree d+1 and
higher (Exercise 6.2). Figure 6.5 illustrates local quadratic regression. Local
linear ﬁts tend to be biased in regions of curvature of the true function, a
phenomenon referred to as trimming the hills and ﬁlling the valleys. Local
quadratic regression is generally able to correct this bias.

P

There is of course a price to be paid for this bias reduction, and that is
increased variance. The ﬁt in the right panel of Figure 6.5 is slightly more
wiggly, especially in the tails. Assuming the model yi = f (xi) + εi, with
εi independent and identically distributed with mean zero and variance
σ2, Var( ˆf (x0)) = σ2
2, where l(x0) is the vector of equivalent kernel
l(x0)
weights at x0. It can be shown (Exercise 6.3) that
increases with d,
and so there is a bias–variance tradeoﬀ in selecting the polynomial degree.
Figure 6.6 illustrates these variance curves for degree zero, one and two

l(x0)

||

||

||

||

198

6. Kernel Smoothing Methods

e
c
n
a
i
r
a
V

5
0

.

4
0

.

3
0

.

2
0

.

1
0

.

0
0

.

Constant
Linear
Quadratic

0.0

0.2

0.4

0.6

0.8

1.0

FIGURE 6.6. The variances functions
quadratic regression, for a metric bandwidth (λ = 0.2) tri-cube kernel.

l(x)

2 for local constant, linear and

||

||

local polynomials. To summarize some collected wisdom on this issue:

•

•

•

Local linear ﬁts can help bias dramatically at the boundaries at a
modest cost in variance. Local quadratic ﬁts do little at the bound-
aries for bias, but increase the variance a lot.

Local quadratic ﬁts tend to be most helpful in reducing bias due to
curvature in the interior of the domain.

Asymptotic analysis suggest that local polynomials of odd degree
dominate those of even degree. This is largely due to the fact that
asymptotically the MSE is dominated by boundary eﬀects.

While it may be helpful to tinker, and move from local linear ﬁts at the
boundary to local quadratic ﬁts in the interior, we do not recommend such
strategies. Usually the application will dictate the degree of the ﬁt. For
example, if we are interested in extrapolation, then the boundary is of
more interest, and local linear ﬁts are probably more reliable.

6.2 Selecting the Width of the Kernel

In each of the kernels Kλ, λ is a parameter that controls its width:

•

•

•

For the Epanechnikov or tri-cube kernel with metric width, λ is the
radius of the support region.

For the Gaussian kernel, λ is the standard deviation.

λ is the number k of nearest neighbors in k-nearest neighborhoods,
often expressed as a fraction or span k/N of the total training sample.

6.2 Selecting the Width of the Kernel

199

•
•
•
•
••
••
••
••••••
••
•
•

••
•
•
••
••
•••••
•
•••••
•

••

••

•••••• •••••••••••••••••••••••••••••• ••••••••••••••• •••••••••••• ••••••••••
•••••• •••••••••••••••••••••••••••••• ••••••••••••••• •••••••••••• ••••••••••

•••••••••••••••••••••• •••••••
•••••••••••••••••••••• ••••••

•••••••••••••••••••
•••••••••••••••••••••••••
•••••
••••••
••••••

•
•

••••••••••••••• •••••••••••• ••••••••••
•••
•••••••••••• •••••••••••• ••••••••••

FIGURE 6.7. Equivalent kernels for a local linear regression smoother (tri-cube
kernel; orange) and a smoothing spline (blue), with matching degrees of freedom.
The vertical spikes indicates the target points.

There is a natural bias–variance tradeoﬀ as we change the width of the
averaging window, which is most explicit for local averages:

•

•

If the window is narrow, ˆf (x0) is an average of a small number of yi
close to x0, and its variance will be relatively large—close to that of
an individual yi. The bias will tend to be small, again because each
of the E(yi) = f (xi) should be close to f (x0).
If the window is wide, the variance of ˆf (x0) will be small relative to
the variance of any yi, because of the eﬀects of averaging. The bias
will be higher, because we are now using observations xi further from
x0, and there is no guarantee that f (xi) will be close to f (x0).

Similar arguments apply to local regression estimates, say local linear: as
the width goes to zero, the estimates approach a piecewise-linear function
that interpolates the training data1; as the width gets inﬁnitely large, the
ﬁt approaches the global linear least-squares ﬁt to the data.

The discussion in Chapter 5 on selecting the regularization parameter for
smoothing splines applies here, and will not be repeated. Local regression
smoothers are linear estimators; the smoother matrix in ˆf = Sλy is built up
Sλ}ij = li(xj). Leave-
from the equivalent kernels (6.8), and has ijth entry
{
one-out cross-validation is particularly simple (Exercise 6.7), as is general-
ized cross-validation, Cp (Exercise 6.10), and k-fold cross-validation. The
eﬀective degrees of freedom is again deﬁned as trace(Sλ), and can be used
to calibrate the amount of smoothing. Figure 6.7 compares the equivalent
kernels for a smoothing spline and local linear regression. The local regres-
sion smoother has a span of 40%, which results in df = trace(Sλ) = 5.86.
The smoothing spline was calibrated to have the same df, and their equiv-
alent kernels are qualitatively quite similar.

1With uniformly spaced xi; with irregularly spaced xi, the behavior can deteriorate.

200

6. Kernel Smoothing Methods

6.3 Local Regression in IRp

Kernel smoothing and local regression generalize very naturally to two or
more dimensions. The Nadaraya–Watson kernel smoother ﬁts a constant
locally with weights supplied by a p-dimensional kernel. Local linear re-
gression will ﬁt a hyperplane locally in X, by weighted least squares, with
weights supplied by a p-dimensional kernel. It is simple to implement and
is generally preferred to the local constant ﬁt for its superior performance
on the boundaries.

Let b(X) be a vector of polynomial terms in X of maximum degree d.
For example, with d = 1 and p = 2 we get b(X) = (1, X1, X2); with d = 2
we get b(X) = (1, X1, X2, X 2
2 , X1X2); and trivially with d = 0 we get
b(X) = 1. At each x0 ∈

1 , X 2
IRp solve

min
β(x0)

N

i=1
X

Kλ(x0, xi)(yi −

b(xi)T β(x0))2

(6.12)

to produce the ﬁt ˆf (x0) = b(x0)T ˆβ(x0). Typically the kernel will be a radial
function, such as the radial Epanechnikov or tri-cube kernel

Kλ(x0, x) = D

x

||

x0||

−
λ

,

(cid:19)

(cid:18)

(6.13)

||·||

where
is the Euclidean norm. Since the Euclidean norm depends on the
units in each coordinate, it makes most sense to standardize each predictor,
for example, to unit standard deviation, prior to smoothing.

While boundary eﬀects are a problem in one-dimensional smoothing,
they are a much bigger problem in two or higher dimensions, since the
fraction of points on the boundary is larger. In fact, one of the manifesta-
tions of the curse of dimensionality is that the fraction of points close to the
boundary increases to one as the dimension grows. Directly modifying the
kernel to accommodate two-dimensional boundaries becomes very messy,
especially for irregular boundaries. Local polynomial regression seamlessly
performs boundary correction to the desired order in any dimensions. Fig-
ure 6.8 illustrates local linear regression on some measurements from an
astronomical study with an unusual predictor design (star-shaped). Here
the boundary is extremely irregular, and the ﬁtted surface must also inter-
polate over regions of increasing data sparsity as we approach the boundary.
Local regression becomes less useful in dimensions much higher than two
or three. We have discussed in some detail the problems of dimensional-
ity, for example, in Chapter 2. It is impossible to simultaneously main-
tain localness (
⇒
low variance) as the dimension increases, without the total sample size in-
creasing exponentially in p. Visualization of ˆf (X) also becomes diﬃcult in
higher dimensions, and this is often one of the primary goals of smoothing.

low bias) and a sizable sample in the neighborhood (

⇒

6.4 Structured Local Regression Models in IRp

201

Velocity

Velocity

South-North

South-North

East-West

East-West

FIGURE 6.8. The left panel shows three-dimensional data, where the response
is the velocity measurements on a galaxy, and the two predictors record positions
on the celestial sphere. The unusual “star”-shaped design indicates the way the
measurements were made, and results in an extremely irregular boundary. The
right panel shows the results of local linear regression smoothing in IR2, using a
nearest-neighbor window with 15% of the data.

Although the scatter-cloud and wire-frame pictures in Figure 6.8 look at-
tractive, it is quite diﬃcult to interpret the results except at a gross level.
From a data analysis perspective, conditional plots are far more useful.

Figure 6.9 shows an analysis of some environmental data with three pre-
dictors. The trellis display here shows ozone as a function of radiation,
conditioned on the other two variables, temperature and wind speed. How-
ever, conditioning on the value of a variable really implies local to that
value (as in local regression). Above each of the panels in Figure 6.9 is an
indication of the range of values present in that panel for each of the condi-
tioning values. In the panel itself the data subsets are displayed (response
versus remaining variable), and a one-dimensional local linear regression is
ﬁt to the data. Although this is not quite the same as looking at slices of
a ﬁtted three-dimensional surface, it is probably more useful in terms of
understanding the joint behavior of the data.

6.4 Structured Local Regression Models in IRp

When the dimension to sample-size ratio is unfavorable, local regression
does not help us much, unless we are willing to make some structural as-
sumptions about the model. Much of this book is about structured regres-
sion and classiﬁcation models. Here we focus on some approaches directly
related to kernel methods.

202

6. Kernel Smoothing Methods

0

50

150

250

0

50

150

250

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

Wind
Temp

5

4

3

2

1

5

4

3

2

1

)
b
p
p

t

o
o
r

e
b
u
c
(

e
n
o
z
O

t
o
o
R
e
b
u
C

5

4

3

2

1

5

4

3

2

1

0

50

150

250

0

50

150

250

Solar Radiation (langleys)

FIGURE 6.9. Three-dimensional smoothing example. The response is (cube-root
of ) ozone concentration, and the three predictors are temperature, wind speed and
radiation. The trellis display shows ozone as a function of radiation, conditioned
on intervals of temperature and wind speed (indicated by darker green or orange
shaded bars). Each panel contains about 40% of the range of each of the condi-
tioned variables. The curve in each panel is a univariate local linear regression,
ﬁt to the data in the panel.

 
 
 
 
 
6.4 Structured Local Regression Models in IRp

203

6.4.1 Structured Kernels

One line of approach is to modify the kernel. The default spherical ker-
nel (6.13) gives equal weight to each coordinate, and so a natural default
strategy is to standardize each variable to unit standard deviation. A more
general approach is to use a positive semideﬁnite matrix A to weigh the
diﬀerent coordinates:

Kλ,A(x0, x) = D

(x

−

x0)T A(x
λ

−

x0)

.

(cid:19)

(cid:18)

(6.14)

Entire coordinates or directions can be downgraded or omitted by imposing
appropriate restrictions on A. For example, if A is diagonal, then we can
increase or decrease the inﬂuence of individual predictors Xj by increasing
or decreasing Ajj. Often the predictors are many and highly correlated,
such as those arising from digitized analog signals or images. The covariance
function of the predictors can be used to tailor a metric A that focuses less,
say, on high-frequency contrasts (Exercise 6.4). Proposals have been made
for learning the parameters for multidimensional kernels. For example, the
projection-pursuit regression model discussed in Chapter 11 is of this ﬂavor,
where low-rank versions of A imply ridge functions for ˆf (X). More general
models for A are cumbersome, and we favor instead the structured forms
for the regression function discussed next.

6.4.2 Structured Regression Functions

We are trying to ﬁt a regression function E(Y
X) = f (X1, X2, . . . , Xp) in
IRp, in which every level of interaction is potentially present. It is natural
to consider analysis-of-variance (ANOVA) decompositions of the form

|

f (X1, X2, . . . , Xp) = α +

gj(Xj) +

gkℓ(Xk, Xℓ) +

j
X

Xk<ℓ

(6.15)

· · ·

and then introduce structure by eliminating some of the higher-order terms.
p
Additive models assume only main eﬀect terms: f (X) = α +
j=1 gj(Xj);
second-order models will have terms with interactions of order at most
two, and so on. In Chapter 9, we describe iterative backﬁtting algorithms
for ﬁtting such low-order interaction models. In the additive model, for
example, if all but the kth term is assumed known, then we can estimate gk
by local regression of Y
j6=k gj(Xj) on Xk. This is done for each function
in turn, repeatedly, until convergence. The important detail is that at any
stage, one-dimensional local regression is all that is needed. The same ideas
can be used to ﬁt low-dimensional ANOVA decompositions.

P

P

−

An important special case of these structured models are the class of
varying coeﬃcient models. Suppose, for example, that we divide the p pre-
dictors in X into a set (X1, X2, . . . , Xq) with q < p, and the remainder of

204

6. Kernel Smoothing Methods

Aortic Diameter vs Age

20

30

40

50

60

20

30

40

50

60

20

30

40

50

60

Male
Depth

Male
Depth

Male
Depth

Male
Depth

Male
Depth

Male
Depth

Female
Depth

Female
Depth

Female
Depth

Female
Depth

Female
Depth

Female
Depth

24

22

20

18

16

14

12

10

r
e
t
e
m
a
D

i

24

22

20

18

16

14

12

10

20

30

40

50

60

20

30

40

50

60

20

30

40

50

60

Age

FIGURE 6.10. In each panel the aorta diameter is modeled as a linear func-
tion of age. The coeﬃcients of this model vary with gender and depth down
the aorta (left is near the top, right is low down). There is a clear trend in the
coeﬃcients of the linear model.

the variables we collect in the vector Z. We then assume the conditionally
linear model

f (X) = α(Z) + β1(Z)X1 +

+ βq(Z)Xq.

· · ·

(6.16)

For given Z, this is a linear model, but each of the coeﬃcients can vary
with Z. It is natural to ﬁt such a model by locally weighted least squares:

N

min
α(z0),β(z0)

Kλ(z0, zi) (yi −

α(z0)

−

x1iβ1(z0)

− · · · −

xqiβq(z0))2 .

(6.17)
Figure 6.10 illustrates the idea on measurements of the human aorta.
A longstanding claim has been that the aorta thickens with age. Here we
model the diameter of the aorta as a linear function of age, but allow the
coeﬃcients to vary with gender and depth down the aorta. We used a local
regression model separately for males and females. While the aorta clearly
does thicken with age at the higher regions of the aorta, the relationship
fades with distance down the aorta. Figure 6.11 shows the intercept and
slope as a function of depth.

i=1
X

6.5 Local Likelihood and Other Models

205

Male

Female

0
2

8
1

6
1

4
1

2
.
1

8
.
0

4
.
0

0
.
0

t
p
e
c
r
e
t
n
I

e
g
A

l

e
p
o
S
e
g
A

0.0

0.2

0.4

0.6

0.8

1.0

0.0

0.2

0.4

0.6

0.8

1.0

Distance Down Aorta

Distance Down Aorta

FIGURE 6.11. The intercept and slope of age as a function of distance down
the aorta, separately for males and females. The yellow bands indicate one stan-
dard error.

6.5 Local Likelihood and Other Models

The concept of local regression and varying coeﬃcient models is extremely
broad: any parametric model can be made local if the ﬁtting method ac-
commodates observation weights. Here are some examples:

•

Associated with each observation yi is a parameter θi = θ(xi) = xT
i β
linear in the covariate(s) xi, and inference for β is based on the log-
i β). We can model θ(X) more ﬂexibly
likelihood l(β) =
by using the likelihood local to x0 for inference of θ(x0) = xT
0 β(x0):

N
i=1 l(yi, xT

P

l(β(x0)) =

N

i=1
X

Kλ(x0, xi)l(yi, xT

i β(x0)).

Many likelihood models, in particular the family of generalized linear
models including logistic and log-linear models, involve the covariates
in a linear fashion. Local likelihood allows a relaxation from a globally
linear model to one that is locally linear.

 
 
206

6. Kernel Smoothing Methods

•

As above, except diﬀerent variables are associated with θ from those
used for deﬁning the local likelihood:

N

l(θ(z0)) =

Kλ(z0, zi)l(yi, η(xi, θ(z0))).

i=1
X

For example, η(x, θ) = xT θ could be a linear model in x. This will ﬁt
a varying coeﬃcient model θ(z) by maximizing the local likelihood.

•

· · ·

Autoregressive time series models of order k have the form yt =
+ βkyt−k + εt. Denoting the lag set by
β0 + β1yt−1 + β2yt−2 +
zt = (yt−1, yt−2, . . . , yt−k), the model looks like a standard linear
model yt = zT
t β + εt, and is typically ﬁt by least squares. Fitting
by local least squares with a kernel K(z0, zt) allows the model to
vary according to the short-term history of the series. This is to be
distinguished from the more traditional dynamic linear models that
vary by windowing time.

As an illustration of local likelihood, we consider the local version of the
multiclass linear logistic regression model (4.36) of Chapter 4. The data
1, 2, . . . , J
consist of features xi and an associated categorical response gi ∈ {
and the linear model has the form

,
}

Pr(G = j

|

X = x) =

1 +

eβj0+βT
j x
J−1
k=1 eβk0+βT
k x

.

(6.18)

The local log-likelihood for this J class model can be written

P

N

i=1
X

Kλ(x0, xi)

βgi0(x0) + βgi (x0)T (xi −

x0)

(

log

−

"

J−1

1 +

exp

Xk=1

(cid:0)

βk0(x0) + βk(x0)T (xi −

x0)

.

#)

(6.19)

(cid:1)

Notice that

•

•

•

we have used gi as a subscript in the ﬁrst line to pick out the appro-
priate numerator;

βJ0 = 0 and βJ = 0 by the deﬁnition of the model;

we have centered the local regressions at x0, so that the ﬁtted poste-
rior probabilities at x0 are simply

ˆPr(G = j

X = x0) =

|

1 +

e ˆβj0(x0)
J−1
k=1 e ˆβk0(x0)

.

P

(6.20)

6.5 Local Likelihood and Other Models

207

D
H
C
e
c
n
e
a
v
e
r
P

l

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

D
H
C
e
c
n
e
a
v
e
r
P

l

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

100

140

180

220

15

25

35

45

Systolic Blood Pressure

Obesity

FIGURE 6.12. Each plot shows the binary response CHD (coronary heart dis-
ease) as a function of a risk factor for the South African heart disease data.
For each plot we have computed the ﬁtted prevalence of CHD using a local linear
logistic regression model. The unexpected increase in the prevalence of CHD at
the lower ends of the ranges is because these are retrospective data, and some of
the subjects had already undergone treatment to reduce their blood pressure and
weight. The shaded region in the plot indicates an estimated pointwise standard
error band.

This model can be used for ﬂexible multiclass classiﬁcation in moderately
low dimensions, although successes have been reported with the high-
dimensional ZIP-code classiﬁcation problem. Generalized additive models
(Chapter 9) using kernel smoothing methods are closely related, and avoid
dimensionality problems by assuming an additive structure for the regres-
sion function.

As a simple illustration we ﬁt a two-class local linear logistic model to
the heart disease data of Chapter 4. Figure 6.12 shows the univariate local
logistic models ﬁt to two of the risk factors (separately). This is a useful
screening device for detecting nonlinearities, when the data themselves have
little visual information to oﬀer. In this case an unexpected anomaly is
uncovered in the data, which may have gone unnoticed with traditional
methods.

|

Since CHD is a binary indicator, we could estimate the conditional preva-
lence Pr(G = j
x0) by simply smoothing this binary response directly with-
out resorting to a likelihood formulation. This amounts to ﬁtting a locally
constant logistic regression model (Exercise 6.5). In order to enjoy the bias-
correction of local-linear smoothing, it is more natural to operate on the
unrestricted logit scale.

Typically with logistic regression, we compute parameter estimates as
well as their standard errors. This can be done locally as well, and so

 
 
208

6. Kernel Smoothing Methods

e
t
a
m

i
t
s
E
y
t
i
s
n
e
D

0
2
0
.
0

5
1
0
.
0

0
1
0
.
0

5
0
0
.
0

0
.
0

100

120

140

160

180

200

220

Systolic Blood Pressure (for CHD group)

FIGURE 6.13. A kernel density estimate for systolic blood pressure (for the
CHD group). The density estimate at each point is the average contribution from
each of the kernels at that point. We have scaled the kernels down by a factor of
10 to make the graph readable.

we can produce, as shown in the plot, estimated pointwise standard-error
bands about our ﬁtted prevalence.

6.6 Kernel Density Estimation and Classiﬁcation

Kernel density estimation is an unsupervised learning procedure, which
historically precedes kernel regression. It also leads naturally to a simple
family of procedures for nonparametric classiﬁcation.

6.6.1 Kernel Density Estimation

Suppose we have a random sample x1, . . . , xN drawn from a probability
density fX (x), and we wish to estimate fX at a point x0. For simplicity we
assume for now that X
IR. Arguing as before, a natural local estimate
has the form

#xi ∈ N
N λ
(x0) is a small metric neighborhood around x0 of width λ. This

where
estimate is bumpy, and the smooth Parzen estimate is preferred

ˆfX (x0) =

(6.21)

(x0)

N

∈

,

ˆfX (x0) =

1
N λ

N

i=1
X

Kλ(x0, xi),

(6.22)

 
6.6 Kernel Density Estimation and Classiﬁcation

209

s
e
t
a
m

i
t
s
E
y
t
i
s
n
e
D

0
2
0
.
0

0
1
0
.
0

0
.
0

CHD
no CHD

e
t
a
m

i
t
s
E

r
o
i
r
e
t
s
o
P

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

100

140

180

220

100

140

180

220

Systolic Blood Pressure

Systolic Blood Pressure

FIGURE 6.14. The left panel shows the two separate density estimates for
systolic blood pressure in the CHD versus no-CHD groups, using a Gaussian
kernel density estimate in each. The right panel shows the estimated posterior
probabilities for CHD, using (6.25).

because it counts observations close to x0 with weights that decrease with
distance from x0. In this case a popular choice for Kλ is the Gaussian kernel
Kλ(x0, x) = φ(
/λ). Figure 6.13 shows a Gaussian kernel density ﬁt
to the sample values for systolic blood pressure for the CHD group. Letting
φλ denote the Gaussian density with mean zero and standard-deviation λ,
then (6.22) has the form

x0|

−

x

|

ˆfX (x) =

N

φλ(x

1
N

i=1
X
= ( ˆF ⋆ φλ)(x),

−

xi)

(6.23)

the convolution of the sample empirical distribution ˆF with φλ. The dis-
tribution ˆF (x) puts mass 1/N at each of the observed xi, and is jumpy; in
ˆfX (x) we have smoothed ˆF by adding independent Gaussian noise to each
observation xi.

The Parzen density estimate is the equivalent of the local average, and
improvements have been proposed along the lines of local regression [on the
log scale for densities; see Loader (1999)]. We will not pursue these here.
In IRp the natural generalization of the Gaussian density estimate amounts
to using the Gaussian product kernel in (6.23),

ˆfX (x0) =

1
N (2λ2π)

p
2

N

i=1
X

e− 1

2 (||xi−x0||/λ)2

.

(6.24)

 
 
210

6. Kernel Smoothing Methods

1.0

0.5

0.0

FIGURE 6.15. The population class densities may have interesting structure
(left) that disappears when the posterior probabilities are formed (right).

6.6.2 Kernel Density Classiﬁcation

One can use nonparametric density estimates for classiﬁcation in a straight-
forward fashion using Bayes’ theorem. Suppose for a J class problem we ﬁt
nonparametric density estimates ˆfj(X), j = 1, . . . , J separately in each of
the classes, and we also have estimates of the class priors ˆπj (usually the
sample proportions). Then

ˆPr(G = j

X = x0) =

|

ˆπj ˆfj(x0)
J
k=1 ˆπk ˆfk(x0)

.

(6.25)

P

Figure 6.14 uses this method to estimate the prevalence of CHD for the
heart risk factor study, and should be compared with the left panel of Fig-
ure 6.12. The main diﬀerence occurs in the region of high SBP in the right
panel of Figure 6.14. In this region the data are sparse for both classes, and
since the Gaussian kernel density estimates use metric kernels, the density
estimates are low and of poor quality (high variance) in these regions. The
local logistic regression method (6.20) uses the tri-cube kernel with k-NN
bandwidth; this eﬀectively widens the kernel in this region, and makes use
of the local linear assumption to smooth out the estimate (on the logit
scale).

If classiﬁcation is the ultimate goal, then learning the separate class den-
sities well may be unnecessary, and can in fact be misleading. Figure 6.15
shows an example where the densities are both multimodal, but the pos-
terior ratio is quite smooth. In learning the separate densities from data,
one might decide to settle for a rougher, high-variance ﬁt to capture these
features, which are irrelevant for the purposes of estimating the posterior
probabilities. In fact, if classiﬁcation is the ultimate goal, then we need only
to estimate the posterior well near the decision boundary (for two classes,
this is the set

X = x) = 1

).

x
{

Pr(G = 1
|

|

2 }

6.6.3 The Naive Bayes Classiﬁer

This is a technique that has remained popular over the years, despite its
name (also known as “Idiot’s Bayes”!) It is especially appropriate when

6.6 Kernel Density Estimation and Classiﬁcation

211

the dimension p of the feature space is high, making density estimation
unattractive. The naive Bayes model assumes that given a class G = j, the
features Xk are independent:

p

fj(X) =

fjk(Xk).

(6.26)

Yk=1
While this assumption is generally not true, it does simplify the estimation
dramatically:

•

•

The individual class-conditional marginal densities fjk can each be
estimated separately using one-dimensional kernel density estimates.
This is in fact a generalization of the original naive Bayes procedures,
which used univariate Gaussians to represent these marginals.

If a component Xj of X is discrete, then an appropriate histogram
estimate can be used. This provides a seamless way of mixing variable
types in a feature vector.

Despite these rather optimistic assumptions, naive Bayes classiﬁers often
outperform far more sophisticated alternatives. The reasons are related to
Figure 6.15: although the individual class density estimates may be biased,
this bias might not hurt the posterior probabilities as much, especially
near the decision regions. In fact, the problem may be able to withstand
considerable bias for the savings in variance such a “naive” assumption
earns.

Starting from (6.26) we can derive the logit-transform (using class J as

the base):

log

Pr(G = ℓ
|
Pr(G = J
|

X)
X)

= log

= log

πℓfℓ(X)
πJ fJ (X)
p
πℓ
k=1 fℓk(Xk)
p
k=1 fJk(Xk)
πJ

Q
Q
+

p

log

fℓk(Xk)
fJk(Xk)

Xk=1
gℓk(Xk).

= log

πℓ
πJ

= αℓ +

p

Xk=1

(6.27)

This has the form of a generalized additive model, which is described in more
detail in Chapter 9. The models are ﬁt in quite diﬀerent ways though; their
diﬀerences are explored in Exercise 6.9. The relationship between naive
Bayes and generalized additive models is analogous to that between linear
discriminant analysis and logistic regression (Section 4.4.5).

212

6. Kernel Smoothing Methods

6.7 Radial Basis Functions and Kernels

P

In Chapter 5, functions are represented as expansions in basis functions:
M
f (x) =
j=1 βjhj(x). The art of ﬂexible modeling using basis expansions
consists of picking an appropriate family of basis functions, and then con-
trolling the complexity of the representation by selection, regularization, or
both. Some of the families of basis functions have elements that are deﬁned
locally; for example, B-splines are deﬁned locally in IR. If more ﬂexibility
is desired in a particular region, then that region needs to be represented
by more basis functions (which in the case of B-splines translates to more
knots). Tensor products of IR-local basis functions deliver basis functions
local in IRp. Not all basis functions are local—for example, the truncated
power bases for splines, or the sigmoidal basis functions σ(α0 + αx) used
in neural-networks (see Chapter 11). The composed function f (x) can nev-
ertheless show local behavior, because of the particular signs and values
of the coeﬃcients causing cancellations of global eﬀects. For example, the
truncated power basis has an equivalent B-spline basis for the same space
of functions; the cancellation is exact in this case.

Kernel methods achieve ﬂexibility by ﬁtting simple models in a region
local to the target point x0. Localization is achieved via a weighting kernel
Kλ, and individual observations receive weights Kλ(x0, xi).

Radial basis functions combine these ideas, by treating the kernel func-

tions Kλ(ξ, x) as basis functions. This leads to the model

f (x) =

M

j=1
X
M

Kλj (ξj, x)βj

=

D

j=1
X

(cid:18)

x

||

ξj||

−
λj

βj,

(cid:19)

(6.28)

where each basis element is indexed by a location or prototype parameter ξj
and a scale parameter λj. A popular choice for D is the standard Gaussian
density function. There are several approaches to learning the parameters
, j = 1, . . . , M . For simplicity we will focus on least squares
λj, ξj, βj}
{
methods for regression, and use the Gaussian kernel.

Optimize the sum-of-squares with respect to all the parameters:

•

N

M

min
{λj ,ξj ,βj }M
1

yi −

β0 −

βj exp



i=1
X

)
(6.29)

This model is commonly referred to as an RBF network, an alterna-
tive to the sigmoidal neural network discussed in Chapter 11; the ξj
and λj playing the role of the weights. This criterion is nonconvex

(−

j=1
X



(xi −

ξj)T (xi −
λ2
j

2

ξj)

.

6.7 Radial Basis Functions and Kernels

213

8

6

4

2

0

2
.
1

8
.
0

4
.
0

0
.
0

FIGURE 6.16. Gaussian radial basis functions in IR with ﬁxed width can leave
holes (top panel). Renormalized Gaussian radial basis functions avoid this prob-
lem, and produce basis functions similar in some respects to B-splines.

with multiple local minima, and the algorithms for optimization are
similar to those used for neural networks.

•

λj, ξj}
{

Estimate the
separately from the βj. Given the former, the
estimation of the latter is a simple least squares problem. Often the
kernel parameters λj and ξj are chosen in an unsupervised way using
the X distribution alone. One of the methods is to ﬁt a Gaussian
mixture density model to the training xi, which provides both the
centers ξj and the scales λj. Other even more adhoc approaches use
clustering methods to locate the prototypes ξj, and treat λj = λ
as a hyper-parameter. The obvious drawback of these approaches is
that the conditional distribution Pr(Y
X)
is having no say in where the action is concentrated. On the positive
side, they are much simpler to implement.

X) and in particular E(Y

|

|

While it would seem attractive to reduce the parameter set and assume
a constant value for λj = λ, this can have an undesirable side eﬀect of
creating holes—regions of IRp where none of the kernels has appreciable
support, as illustrated in Figure 6.16 (upper panel). Renormalized radial
basis functions,

hj(x) =

D(
x
||
M
k=1 D(

ξj||
−
x
−

||

/λ)
ξk||

/λ)

,

(6.30)

avoid this problem (lower panel).
P

The Nadaraya–Watson kernel regression estimator (6.2) in IRp can be

viewed as an expansion in renormalized radial basis functions,

ˆf (x0) =

PN

Kλ(x0,xi)
i=1 Kλ(x0,xi)

N
i=1 yi
N
i=1 yihi(x0)

P
=

P

(6.31)

214

6. Kernel Smoothing Methods

with a basis function hi located at every observation and coeﬃcients yi;
that is, ξi = xi, ˆβi = yi, i = 1, . . . , N .

Note the similarity between the expansion (6.31) and the solution (5.50)
on page 169 to the regularization problem induced by the kernel K. Radial
basis functions form the bridge between the modern “kernel methods” and
local ﬁtting technology.

6.8 Mixture Models for Density Estimation and

Classiﬁcation

The mixture model is a useful tool for density estimation, and can be viewed
as a kind of kernel method. The Gaussian mixture model has the form

M

f (x) =

αmφ(x; µm, Σm)

(6.32)

m=1
X

m αm = 1, and each Gaussian density has
with mixing proportions αm,
a mean µm and covariance matrix Σm. In general, mixture models can use
any component densities in place of the Gaussian in (6.32): the Gaussian
mixture model is by far the most popular.

P

The parameters are usually ﬁt by maximum likelihood, using the EM

algorithm as described in Chapter 8. Some special cases arise:

•

•

If the covariance matrices are constrained to be scalar: Σm = σmI,
then (6.32) has the form of a radial basis expansion.

If in addition σm = σ > 0 is ﬁxed, and M
N , then the max-
imum likelihood estimate for (6.32) approaches the kernel density
estimate (6.22) where ˆαm = 1/N and ˆµm = xm.

↑

Using Bayes’ theorem, separate mixture densities in each class lead to ﬂex-
ible models for Pr(G
|

X); this is taken up in some detail in Chapter 12.

Figure 6.17 shows an application of mixtures to the heart disease risk-
factor study. In the top row are histograms of Age for the no CHD and CHD
groups separately, and then combined on the right. Using the combined
data, we ﬁt a two-component mixture of the form (6.32) with the (scalars)
Σ1 and Σ2 not constrained to be equal. Fitting was done via the EM
algorithm (Chapter 8): note that the procedure does not use knowledge of
the CHD labels. The resulting estimates were
ˆΣ1 = 157.7,
ˆΣ2 = 15.6,
The component densities φ(ˆµ1, ˆΣ1) and φ(ˆµ2, ˆΣ2) are shown in the lower-
left and middle panels. The lower-right panel shows these component den-
sities (orange and blue) along with the estimated mixture density (green).

ˆµ1 = 36.4,
ˆµ2 = 58.0,

ˆα1 = 0.7,
ˆα2 = 0.3.

6.8 Mixture Models for Density Estimation and Classiﬁcation

215

No CHD

CHD

Combined

20

30

40

50

60

Age

t
n
u
o
C

e
t
a
m

i
t
s
E
e
r
u
t
x
M

i

0
2

5
1

0
1

5

0

0
1
.
0

8
0
.
0

6
0
.
0

4
0
.
0

2
0
.
0

0
0
.
0

t
n
u
o
C

e
t
a
m

i
t
s
E
e
r
u
t
x
M

i

5
1

0
1

5

0

0
1
.
0

8
0
.
0

6
0
.
0

4
0
.
0

2
0
.
0

0
0
.
0

20

30

40

50

60

Age

0
3

5
2

0
2

5
1

0
1

5

0

0
1
.
0

8
0
.
0

6
0
.
0

4
0
.
0

2
0
.
0

0
0
.
0

t
n
u
o
C

e
t
a
m

i
t
s
E
e
r
u
t
x
M

i

20

30

40

50

60

Age

20

30

40

50

60

20

30

40

50

60

20

30

40

50

60

Age

Age

Age

FIGURE 6.17. Application of mixtures to the heart disease risk-factor study.
(Top row:) Histograms of Age for the no CHD and CHD groups separately, and
combined. (Bottom row:) estimated component densities from a Gaussian mix-
ture model, (bottom left, bottom middle); (bottom right:) Estimated component
densities (blue and orange) along with the estimated mixture density (green). The
orange density has a very large standard deviation, and approximates a uniform
density.

The mixture model also provides an estimate of the probability that

observation i belongs to component m,

ˆrim =

ˆαmφ(xi; ˆµm, ˆΣm)
M
k=1 ˆαkφ(xi; ˆµk, ˆΣk)

,

(6.33)

where xi is Age in our example. Suppose we threshold each value ˆri2 and
hence deﬁne ˆδi = I(ˆri2 > 0.5). Then we can compare the classiﬁcation of
each observation by CHD and the mixture model:

P

Mixture model
ˆδ = 1
ˆδ = 0
70
232
84
76

CHD No
Yes

Although the mixture model did not use the CHD labels, it has done a fair
job in discovering the two CHD subpopulations. Linear logistic regression,
using the CHD as a response, achieves the same error rate (32%) when ﬁt to
these data using maximum-likelihood (Section 4.4).

 
 
 
216

6. Kernel Smoothing Methods

6.9 Computational Considerations

Kernel and local regression and density estimation are memory-based meth-
ods: the model is the entire training data set, and the ﬁtting is done at
evaluation or prediction time. For many real-time applications, this can
make this class of methods infeasible.

The computational cost to ﬁt at a single observation x0 is O(N ) ﬂops,
except in oversimpliﬁed cases (such as square kernels). By comparison,
an expansion in M basis functions costs O(M ) for one evaluation, and
O(log N ). Basis function methods have an initial cost of at
typically M
least O(N M 2 + M 3).

∼

The smoothing parameter(s) λ for kernel methods are typically deter-
mined oﬀ-line, for example using cross-validation, at a cost of O(N 2) ﬂops.
Popular implementations of local regression, such as the loess function in
S-PLUS and R and the locfit procedure (Loader, 1999), use triangulation
schemes to reduce the computations. They compute the ﬁt exactly at M
carefully chosen locations (O(N M )), and then use blending techniques to
interpolate the ﬁt elsewhere (O(M ) per evaluation).

Bibliographic Notes

There is a vast literature on kernel methods which we will not attempt to
summarize. Rather we will point to a few good references that themselves
have extensive bibliographies. Loader (1999) gives excellent coverage of lo-
cal regression and likelihood, and also describes state-of-the-art software
for ﬁtting these models. Fan and Gijbels (1996) cover these models from
a more theoretical aspect. Hastie and Tibshirani (1990) discuss local re-
gression in the context of additive modeling. Silverman (1986) gives a good
overview of density estimation, as does Scott (1992).

Exercises

Ex. 6.1 Show that the Nadaraya–Watson kernel smooth with ﬁxed metric
bandwidth λ and a Gaussian kernel is diﬀerentiable. What can be said for
the Epanechnikov kernel? What can be said for the Epanechnikov kernel
with adaptive nearest-neighbor bandwidth λ(x0)?

N

N

Ex. 6.2 Show that
i=1(xi −
x0)li(x0) = 0 for local linear regression. Deﬁne
x0)jli(x0). Show that b0(x0) = 1 for local polynomial
bj(x0) =
regression of any degree (including local constants). Show that bj(x0) = 0
for local polynomial regression of degree k. What
for all j
are the implications of this on the bias?

i=1(xi −
P
1, 2, . . . , k

P
∈ {

}

Exercises

217

Ex. 6.3 Show that
local polynomial.

||

l(x)

||

(Section 6.1.2) increases with the degree of the

|

Ex. 6.4 Suppose that the p predictors X arise from sampling relatively
smooth analog curves at p uniformly spaced abscissa values. Denote by
Y ) = Σ the conditional covariance matrix of the predictors, and
Cov(X
assume this does not change much with Y . Discuss the nature of Maha-
lanobis choice A = Σ−1 for the metric in (6.14). How does this compare
with A = I? How might you construct a kernel A that (a) downweights
high-frequency components in the distance metric; (b) ignores them
completely?

Ex. 6.5 Show that ﬁtting a locally constant multinomial logit model of
the form (6.19) amounts to smoothing the binary response indicators for
each class separately using a Nadaraya–Watson kernel smoother with kernel
weights Kλ(x0, xi).

Ex. 6.6 Suppose that all you have is software for ﬁtting local regression,
but you can specify exactly which monomials are included in the ﬁt. How
could you use this software to ﬁt a varying-coeﬃcient model in some of the
variables?

Ex. 6.7 Derive an expression for the leave-one-out cross-validated residual
sum-of-squares for local polynomial regression.

Ex. 6.8 Suppose that for continuous response Y and predictor X, we model
the joint density of X, Y using a multivariate Gaussian kernel estimator.
Note that the kernel in this case would be the product kernel φλ(X)φλ(Y ).
X) derived from this estimate is a
Show that the conditional mean E(Y
Nadaraya–Watson estimator. Extend this result to classiﬁcation by pro-
viding a suitable kernel for the estimation of the joint distribution of a
continuous X and discrete Y .

|

Ex. 6.9 Explore the diﬀerences between the naive Bayes model (6.27) and
a generalized additive logistic regression model, in terms of (a) model as-
sumptions and (b) estimation. If all the variables Xk are discrete, what can
you say about the corresponding GAM?

Ex. 6.10 Suppose we have N samples generated from the model yi = f (xi)+
εi, with εi independent and identically distributed with mean zero and
variance σ2, the xi assumed ﬁxed (non random). We estimate f using a
linear smoother (local regression, smoothing spline, etc.) with smoothing
parameter λ. Thus the vector of ﬁtted values is given by ˆf = Sλy. Consider
the in-sample prediction error

PE(λ) = E

1
N

N

i=1
X

(y∗

i −

ˆfλ(xi))2

(6.34)

218

6. Kernel Smoothing Methods

for predicting new responses at the N input values. Show that the aver-
age squared residual on the training data, ASR(λ), is a biased estimate
(optimistic) for PE(λ), while

Cλ = ASR(λ) +

2σ2
N

trace(Sλ)

(6.35)

is unbiased.

Ex. 6.11 Show that for the Gaussian mixture model (6.32) the likelihood
is maximized at +

, and describe how.

∞

Ex. 6.12 Write a computer program to perform a local linear discrimi-
nant analysis. At each query point x0, the training data receive weights
Kλ(x0, xi) from a weighting kernel, and the ingredients for the linear deci-
sion boundaries (see Section 4.3) are computed by weighted averages. Try
out your program on the zipcode data, and show the training and test er-
rors for a series of ﬁve pre-chosen values of λ. The zipcode data are available
from the book website www-stat.stanford.edu/ElemStatLearn.

7
Model Assessment and Selection

This is page 219
Printer: Opaque this

7.1

Introduction

The generalization performance of a learning method relates to its predic-
tion capability on independent test data. Assessment of this performance
is extremely important in practice, since it guides the choice of learning
method or model, and gives us a measure of the quality of the ultimately
chosen model.

In this chapter we describe and illustrate the key methods for perfor-
mance assessment, and show how they are used to select models. We begin
the chapter with a discussion of the interplay between bias, variance and
model complexity.

7.2 Bias, Variance and Model Complexity

Figure 7.1 illustrates the important issue in assessing the ability of a learn-
ing method to generalize. Consider ﬁrst the case of a quantitative or interval
scale response. We have a target variable Y , a vector of inputs X, and a
prediction model ˆf (X) that has been estimated from a training set
.
T
The loss function for measuring errors between Y and ˆf (X) is denoted by
L(Y, ˆf (X)). Typical choices are

L(Y, ˆf (X)) =

(Y
Y

|

−
−

(

ˆf (X))2
ˆf (X)

|

squared error
absolute error.

(7.1)

220

7. Model Assessment and Selection

High Bias

Low Variance

Low Bias

High Variance

r
o
r
r

E
n
o
i
t
c
d
e
r
P

i

2
.
1

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
0

.

0

5

10

15

20

25

30

35

Model Complexity (df)

FIGURE 7.1. Behavior of test sample and training sample error as the model
complexity is varied. The light blue curves show the training error err, while the
light red curves show the conditional test error ErrT for 100 training sets of size
50 each, as the model complexity is increased. The solid curves show the expected
test error Err and the expected training error E[err].

Test error, also referred to as generalization error, is the prediction error
over an independent test sample

ErrT = E[L(Y, ˆf (X))

]

|T

(7.2)

where both X and Y are drawn randomly from their joint distribution
is ﬁxed, and test error refers to the
(population). Here the training set
T
error for this speciﬁc training set. A related quantity is the expected pre-
diction error (or expected test error)

Err = E[L(Y, ˆf (X))] = E[ErrT ].

(7.3)

Note that this expectation averages over everything that is random, includ-
ing the randomness in the training set that produced ˆf .

Figure 7.1 shows the prediction error (light red curves) ErrT for 100
simulated training sets each of size 50. The lasso (Section 3.4.2) was used
to produce the sequence of ﬁts. The solid red curve is the average, and
hence an estimate of Err.

Estimation of ErrT will be our goal, although we will see that Err is
more amenable to statistical analysis, and most methods eﬀectively esti-
mate the expected error. It does not seem possible to estimate conditional

 
7.2 Bias, Variance and Model Complexity

221

error eﬀectively, given only the information in the same training set. Some
discussion of this point is given in Section 7.12.

Training error is the average loss over the training sample

N

L(yi, ˆf (xi)).

(7.4)

err =

1
N

i=1
X

We would like to know the expected test error of our estimated model
ˆf . As the model becomes more and more complex, it uses the training
data more and is able to adapt to more complicated underlying structures.
Hence there is a decrease in bias but an increase in variance. There is some
intermediate model complexity that gives minimum expected test error.

Unfortunately training error is not a good estimate of the test error,
as seen in Figure 7.1. Training error consistently decreases with model
complexity, typically dropping to zero if we increase the model complexity
enough. However, a model with zero training error is overﬁt to the training
data and will typically generalize poorly.

The story is similar for a qualitative or categorical response G taking
, labeled for convenience as 1, 2, . . . , K. Typically
one of K values in a set
G
we model the probabilities pk(X) = Pr(G = k
X) (or some monotone
transformations fk(X)), and then ˆG(X) = arg maxk ˆpk(X). In some cases,
such as 1-nearest neighbor classiﬁcation (Chapters 2 and 13) we produce
ˆG(X) directly. Typical loss functions are
= ˆG(X))
L(G, ˆG(X)) = I(G
K

(0–1 loss),

(7.5)

|

L(G, ˆp(X)) =

2

−

I(G = k) log ˆpk(X)

Xk=1

=

2 log ˆpG(X)

(

2

log-likelihood).

−

−
the log-likelihood is sometimes referred to as the

×

(7.6)

The quantity
deviance.

2

−

×

Again, test error here is ErrT = E[L(G, ˆG(X))

classiﬁcation error of the classiﬁer trained on
misclassiﬁcation error.

T

Training error is the sample analogue, for example,

], the population mis-
, and Err is the expected

|T

N

log ˆpgi(xi),

(7.7)

err =

2
N

−

i=1
X

the sample log-likelihood for the model.

The log-likelihood can be used as a loss-function for general response
densities, such as the Poisson, gamma, exponential, log-normal and others.
If Prθ(X)(Y ) is the density of Y , indexed by a parameter θ(X) that depends
on the predictor X, then

L(Y, θ(X)) =

2

−

·

log Prθ(X)(Y ).

(7.8)

6
222

7. Model Assessment and Selection

2” in the deﬁnition makes the log-likelihood loss for the Gaussian

The “
distribution match squared-error loss.

−

For ease of exposition, for the remainder of this chapter we will use Y and
f (X) to represent all of the above situations, since we focus mainly on the
quantitative response (squared-error loss) setting. For the other situations,
the appropriate translations are obvious.

In this chapter we describe a number of methods for estimating the
expected test error for a model. Typically our model will have a tuning
parameter or parameters α and so we can write our predictions as ˆfα(x).
The tuning parameter varies the complexity of our model, and we wish to
ﬁnd the value of α that minimizes error, that is, produces the minimum of
the average test error curve in Figure 7.1. Having said this, for brevity we
will often suppress the dependence of ˆf (x) on α.

It is important to note that there are in fact two separate goals that we

might have in mind:

Model selection: estimating the performance of diﬀerent models in order

to choose the best one.

Model assessment: having chosen a ﬁnal model, estimating its predic-

tion error (generalization error) on new data.

If we are in a data-rich situation, the best approach for both problems is
to randomly divide the dataset into three parts: a training set, a validation
set, and a test set. The training set is used to ﬁt the models; the validation
set is used to estimate prediction error for model selection; the test set is
used for assessment of the generalization error of the ﬁnal chosen model.
Ideally, the test set should be kept in a “vault,” and be brought out only
at the end of the data analysis. Suppose instead that we use the test-set
repeatedly, choosing the model with smallest test-set error. Then the test
set error of the ﬁnal chosen model will underestimate the true test error,
sometimes substantially.

It is diﬃcult to give a general rule on how to choose the number of
observations in each of the three parts, as this depends on the signal-to-
noise ratio in the data and the training sample size. A typical split might
be 50% for training, and 25% each for validation and testing:

Train
Train
Train
Train

Validation
Validation
Validation
Validation

Test
Test
Test
Test

The methods in this chapter are designed for situations where there is
insuﬃcient data to split it into three parts. Again it is too diﬃcult to give
a general rule on how much training data is enough; among other things,
this depends on the signal-to-noise ratio of the underlying function, and
the complexity of the models being ﬁt to the data.

7.3 The Bias–Variance Decomposition

223

The methods of this chapter approximate the validation step either an-
alytically (AIC, BIC, MDL, SRM) or by eﬃcient sample re-use (cross-
validation and the bootstrap). Besides their use in model selection, we also
examine to what extent each method provides a reliable estimate of test
error of the ﬁnal chosen model.

Before jumping into these topics, we ﬁrst explore in more detail the

nature of test error and the bias–variance tradeoﬀ.

7.3 The Bias–Variance Decomposition

As in Chapter 2, if we assume that Y = f (X) + ε where E(ε) = 0 and
Var(ε) = σ2
ε , we can derive an expression for the expected prediction error
of a regression ﬁt ˆf (X) at an input point X = x0, using squared-error loss:

Err(x0) = E[(Y

ˆf (x0))2

X = x0]
|
f (x0)]2 + E[ ˆf (x0)

−
ε + [E ˆf (x0)
= σ2
ε + Bias2( ˆf (x0)) + Var( ˆf (x0))
= σ2
= Irreducible Error + Bias2 + Variance.

−

−

E ˆf (x0)]2

(7.9)

The ﬁrst term is the variance of the target around its true mean f (x0), and
cannot be avoided no matter how well we estimate f (x0), unless σ2
ε = 0.
The second term is the squared bias, the amount by which the average of
our estimate diﬀers from the true mean; the last term is the variance; the
expected squared deviation of ˆf (x0) around its mean. Typically the more
complex we make the model ˆf , the lower the (squared) bias but the higher
the variance.

For the k-nearest-neighbor regression ﬁt, these expressions have the sim-

ple form

Err(x0) = E[(Y

−

ˆfk(x0))2

= σ2

ε +

f (x0)

−

"

|
1
k

X = x0]

f (x(ℓ))

2

#

+

σ2
ε
k

.

k

Xℓ=1

(7.10)

Here we assume for simplicity that training inputs xi are ﬁxed, and the ran-
domness arises from the yi. The number of neighbors k is inversely related
to the model complexity. For small k, the estimate ˆfk(x) can potentially
adapt itself better to the underlying f (x). As we increase k, the bias—the
squared diﬀerence between f (x0) and the average of f (x) at the k-nearest
neighbors—will typically increase, while the variance decreases.

For a linear model ﬁt ˆfp(x) = xT ˆβ, where the parameter vector β with

p components is ﬁt by least squares, we have

Err(x0) = E[(Y

ˆfp(x0))2

X = x0]

|

−

224

7. Model Assessment and Selection

= σ2

ε + [f (x0)

E ˆfp(x0)]2 +

h(x0)

2σ2
ε .

(7.11)

−
Here h(x0) = X(XT X)−1x0, the N -vector of linear weights that produce
the ﬁt ˆfp(x0) = x0
2σ2
ε .
While this variance changes with x0, its average (with x0 taken to be each
of the sample values xi) is (p/N )σ2

T (XT X)−1XT y, and hence Var[ ˆfp(x0)] =

ε , and hence

h(x0)

||

||

||

||

1
N

N

i=1
X

Err(xi) = σ2

ε +

1
N

N

i=1
X

[f (xi)

−

E ˆf (xi)]2 +

p
N

σ2
ε ,

(7.12)

the in-sample error. Here model complexity is directly related to the num-
ber of parameters p.

The test error Err(x0) for a ridge regression ﬁt ˆfα(x0) is identical in
form to (7.11), except the linear weights in the variance term are diﬀerent:
h(x0) = X(XT X + αI)−1x0. The bias term will also be diﬀerent.

For a linear model family such as ridge regression, we can break down
the bias more ﬁnely. Let β∗ denote the parameters of the best-ﬁtting linear
approximation to f :

β∗ = arg min

β

E

f (X)

−

X T β

2

.

(7.13)

Here the expectation is taken with respect to the distribution of the input
variables X. Then we can write the average squared bias as

(cid:0)

(cid:1)

Ex0

f (x0)

h

E ˆfα(x0)

−

2

i

= Ex0

f (x0)

2

xT
0 β∗

+ Ex0

−

xT
0 β∗ −

ExT
0

ˆβα

(cid:3)
= Ave[Model Bias]2 + Ave[Estimation Bias]2

(cid:2)

h

2

i

(7.14)

The ﬁrst term on the right-hand side is the average squared model bias, the
error between the best-ﬁtting linear approximation and the true function.
The second term is the average squared estimation bias, the error between
the average estimate E(xT
0

ˆβ) and the best-ﬁtting linear approximation.

For linear models ﬁt by ordinary least squares, the estimation bias is zero.
For restricted ﬁts, such as ridge regression, it is positive, and we trade it oﬀ
with the beneﬁts of a reduced variance. The model bias can only be reduced
by enlarging the class of linear models to a richer collection of models, by
including interactions and transformations of the variables in the model.

Figure 7.2 shows the bias–variance tradeoﬀ schematically. In the case
of linear models, the model space is the set of all linear predictions from
p inputs and the black dot labeled “closest ﬁt” is xT β∗. The blue-shaded
region indicates the error σε with which we see the truth in the training
sample.

Also shown is the variance of the least squares ﬁt, indicated by the large
yellow circle centered at the black dot labeled “closest ﬁt in population,’

7.3 The Bias–Variance Decomposition

225

Closest fit in population

Realization

Closest fit

Truth

Model bias

Estimation Bias

Estimation
Variance

MODEL
SPACE

Shrunken fit

RESTRICTED
MODEL SPACE

FIGURE 7.2. Schematic of the behavior of bias and variance. The model space
is the set of all possible predictions from the model, with the “closest ﬁt” labeled
with a black dot. The model bias from the truth is shown, along with the variance,
indicated by the large yellow circle centered at the black dot labeled “closest ﬁt
in population.” A shrunken or regularized ﬁt is also shown, having additional
estimation bias, but smaller prediction error due to its decreased variance.

226

7. Model Assessment and Selection

Now if we were to ﬁt a model with fewer predictors, or regularize the coef-
ﬁcients by shrinking them toward zero (say), we would get the “shrunken
ﬁt” shown in the ﬁgure. This ﬁt has an additional estimation bias, due to
the fact that it is not the closest ﬁt in the model space. On the other hand,
it has smaller variance. If the decrease in variance exceeds the increase in
(squared) bias, then this is worthwhile.

7.3.1 Example: Bias–Variance Tradeoﬀ

Figure 7.3 shows the bias–variance tradeoﬀ for two simulated examples.
There are 80 observations and 20 predictors, uniformly distributed in the
hypercube [0, 1]20. The situations are as follows:

Left panels: Y is 0 if X1 ≤

neighbors.

1/2 and 1 if X1 > 1/2, and we apply k-nearest

Right panels: Y is 1 if

10
j=1 Xj is greater than 5 and 0 otherwise, and we

use best subset linear regression of size p.

P

The top row is regression with squared error loss; the bottom row is classi-
ﬁcation with 0–1 loss. The ﬁgures show the prediction error (red), squared
bias (green) and variance (blue), all computed for a large test sample.

≥

In the regression problems, bias and variance add to produce the predic-
tion error curves, with minima at about k = 5 for k-nearest neighbors, and
p
10 for the linear model. For classiﬁcation loss (bottom ﬁgures), some
interesting phenomena can be seen. The bias and variance curves are the
same as in the top ﬁgures, and prediction error now refers to misclassiﬁ-
cation rate. We see that prediction error is no longer the sum of squared
bias and variance. For the k-nearest neighbor classiﬁer, prediction error
decreases or stays the same as the number of neighbors is increased to 20,
despite the fact that the squared bias is rising. For the linear model classi-
ﬁer the minimum occurs for p
10 as in regression, but the improvement
over the p = 1 model is more dramatic. We see that bias and variance seem
to interact in determining prediction error.

≥

Why does this happen? There is a simple explanation for the ﬁrst phe-
nomenon. Suppose at a given input point, the true probability of class 1 is
0.9 while the expected value of our estimate is 0.6. Then the squared bias—
0.9)2—is considerable, but the prediction error is zero since we make
(0.6
the correct decision. In other words, estimation errors that leave us on the
right side of the decision boundary don’t hurt. Exercise 7.2 demonstrates
this phenomenon analytically, and also shows the interaction eﬀect between
bias and variance.

−

The overall point is that the bias–variance tradeoﬀ behaves diﬀerently
for 0–1 loss than it does for squared error loss. This in turn means that
the best choices of tuning parameters may diﬀer substantially in the two

7.3 The Bias–Variance Decomposition

227

k−NN − Regression

Linear Model − Regression

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

50

40

30

20

10

0

Number of Neighbors k

k−NN − Classification

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

5

10

15

20

Subset Size p

Linear Model − Classification

50

40

30

20

10

0

5

10

15

20

Number of Neighbors k

Subset Size p

FIGURE 7.3. Expected prediction error (orange), squared bias (green) and vari-
ance (blue) for a simulated example. The top row is regression with squared error
loss; the bottom row is classiﬁcation with 0–1 loss. The models are k-nearest
neighbors (left) and best subset regression of size p (right). The variance and bias
curves are the same in regression and classiﬁcation, but the prediction error curve
is diﬀerent.

228

7. Model Assessment and Selection

settings. One should base the choice of tuning parameter on an estimate of
prediction error, as described in the following sections.

7.4 Optimism of the Training Error Rate

Discussions of error rate estimation can be confusing, because we have
to make clear which quantities are ﬁxed and which are random1. Before
we continue, we need a few deﬁnitions, elaborating on the material of Sec-
the gen-
tion 7.2. Given a training set
T
eralization error of a model ˆf is

(x1, y1), (x2, y2), . . . (xN , yN )
{

=

}

ErrT = EX 0,Y 0[L(Y 0, ˆf (X 0))

];

|T

(7.15)

is ﬁxed in expression (7.15). The point (X 0, Y 0)
Note that the training set
is a new test data point, drawn from F , the joint distribution of the data.
Averaging over training sets

yields the expected error

T

T

Err = ET EX 0,Y 0 [L(Y 0, ˆf (X 0))

],

|T

(7.16)

which is more amenable to statistical analysis. As mentioned earlier, it
turns out that most methods eﬀectively estimate the expected error rather
than ET ; see Section 7.12 for more on this point.

Now typically, the training error

err =

1
N

N

i=1
X

L(yi, ˆf (xi))

(7.17)

will be less than the true error ErrT , because the same data is being used
to ﬁt the method and assess its error (see Exercise 2.9). A ﬁtting method
typically adapts to the training data, and hence the apparent or training
error err will be an overly optimistic estimate of the generalization error
ErrT .

Part of the discrepancy is due to where the evaluation points occur. The
quantity ErrT can be thought of as extra-sample error, since the test input
vectors don’t need to coincide with the training input vectors. The nature
of the optimism in err is easiest to understand when we focus instead on
the in-sample error

Errin =

1
N

N

i=1
X

EY 0 [L(Y 0

i , ˆf (xi))

]

|T

(7.18)

The Y 0 notation indicates that we observe N new response values at
each of the training points xi, i = 1, 2, . . . , N . We deﬁne the optimism as

1Indeed, in the ﬁrst edition of our book, this section wasn’t suﬃciently clear.

7.4 Optimism of the Training Error Rate

229

the diﬀerence between Errin and the training error err:

op

Errin −
This is typically positive since err is usually biased downward as an estimate
of prediction error. Finally, the average optimism is the expectation of the
optimism over training sets

(7.19)

err.

≡

Ey(op).

ω

≡

(7.20)

Here the predictors in the training set are ﬁxed, and the expectation is
over the training set outcome values; hence we have used the notation Ey
instead of ET . We can usually estimate only the expected error ω rather
than op, in the same way that we can estimate the expected error Err
rather than the conditional error ErrT .

For squared error, 0–1, and other loss functions, one can show quite

generally that

ω =

2
N

N

i=1
X

Cov(ˆyi, yi),

(7.21)

where Cov indicates covariance. Thus the amount by which err underesti-
mates the true error depends on how strongly yi aﬀects its own prediction.
The harder we ﬁt the data, the greater Cov(ˆyi, yi) will be, thereby increas-
ing the optimism. Exercise 7.4 proves this result for squared error loss where
ˆyi is the ﬁtted value from the regression. For 0–1 loss, ˆyi ∈ {
is the
[0, 1] is the ﬁtted probability
classiﬁcation at xi, and for entropy loss, ˆyi ∈
of class 1 at xi.
In summary, we have the important relation

0, 1
}

Ey(Errin) = Ey(err) +

2
N

N

i=1
X

Cov(ˆyi, yi).

(7.22)

This expression simpliﬁes if ˆyi is obtained by a linear ﬁt with d inputs

or basis functions. For example,

N

Cov(ˆyi, yi) = dσ2
ε

i=1
X
for the additive error model Y = f (X) + ε, and so

Ey(Errin) = Ey(err) + 2

d
N

·

σ2
ε .

(7.23)

(7.24)

Expression (7.23) is the basis for the deﬁnition of the eﬀective number of
parameters discussed in Section 7.6 The optimism increases linearly with

230

7. Model Assessment and Selection

the number d of inputs or basis functions we use, but decreases as the
training sample size increases. Versions of (7.24) hold approximately for
other error models, such as binary data and entropy loss.

An obvious way to estimate prediction error is to estimate the optimism
and then add it to the training error err. The methods described in the
next section—Cp, AIC, BIC and others—work in this way, for a special
class of estimates that are linear in their parameters.

In contrast, cross-validation and bootstrap methods, described later in
the chapter, are direct estimates of the extra-sample error Err. These gen-
eral tools can be used with any loss function, and with nonlinear, adaptive
ﬁtting techniques.

In-sample error is not usually of direct interest since future values of the
features are not likely to coincide with their training set values. But for
comparison between models, in-sample error is convenient and often leads
to eﬀective model selection. The reason is that the relative (rather than
absolute) size of the error is what matters.

7.5 Estimates of In-Sample Prediction Error

The general form of the in-sample estimates is

Errin = err + ˆω,

(7.25)

where ˆω is an estimate of the average optimism.

d

Using expression (7.24), applicable when d parameters are ﬁt under

squared error loss, leads to a version of the so-called Cp statistic,

Cp = err + 2

d
N

·

ˆσε

2.

(7.26)

2 is an estimate of the noise variance, obtained from the mean-
Here ˆσε
squared error of a low-bias model. Using this criterion we adjust the training
error by a factor proportional to the number of basis functions used.

The Akaike information criterion is a similar but more generally appli-
cable estimate of Errin when a log-likelihood loss function is used. It relies
on a relationship similar to (7.24) that holds asymptotically as N

:

→ ∞

2

−

·

E[log Prˆθ(Y )]

2
N ·

≈ −

E[loglik] + 2

d
N

.

·

(7.27)

Here Prθ(Y ) is a family of densities for Y (containing the “true” density),
ˆθ is the maximum-likelihood estimate of θ, and “loglik” is the maximized
log-likelihood:

loglik =

N

i=1
X

log Prˆθ(yi).

(7.28)

7.5 Estimates of In-Sample Prediction Error

231

For example, for the logistic regression model, using the binomial log-
likelihood, we have

AIC =

2
N ·

−

loglik + 2

d
N

.

·

(7.29)

2 assumed known), the AIC
For the Gaussian model (with variance σ2
statistic is equivalent to Cp, and so we refer to them collectively as AIC.

ε = ˆσε

To use AIC for model selection, we simply choose the model giving small-
est AIC over the set of models considered. For nonlinear and other complex
models, we need to replace d by some measure of model complexity. We
discuss this in Section 7.6.

Given a set of models fα(x) indexed by a tuning parameter α, denote
by err(α) and d(α) the training error and number of parameters for each
model. Then for this set of models we deﬁne

AIC(α) = err(α) + 2

d(α)
N

·

ˆσε

2.

(7.30)

The function AIC(α) provides an estimate of the test error curve, and we
ﬁnd the tuning parameter ˆα that minimizes it. Our ﬁnal chosen model
is f ˆα(x). Note that if the basis functions are chosen adaptively, (7.23) no
longer holds. For example, if we have a total of p inputs, and we choose
the best-ﬁtting linear model with d < p inputs, the optimism will exceed
(2d/N )σ2
ε . Put another way, by choosing the best-ﬁtting model with d
inputs, the eﬀective number of parameters ﬁt is more than d.

Figure 7.4 shows AIC in action for the phoneme recognition example
of Section 5.2.3 on page 148. The input vector is the log-periodogram of
the spoken vowel, quantized to 256 uniformly spaced frequencies. A lin-
ear logistic regression model is used to predict the phoneme class, with
M
coeﬃcient function β(f ) =
m=1 hm(f )θm, an expansion in M spline ba-
sis functions. For any given M , a basis of natural cubic splines is used
for the hm, with knots chosen uniformly over the range of frequencies (so
d(α) = d(M ) = M ). Using AIC to select the number of basis functions will
approximately minimize Err(M ) for both entropy and 0–1 loss.

P

The simple formula

(2/N )

N

i=1
X

Cov(ˆyi, yi) = (2d/N )σ2
ε

holds exactly for linear models with additive errors and squared error loss,
and approximately for linear models and log-likelihoods. In particular, the
formula does not hold in general for 0–1 loss (Efron, 1986), although many
authors nevertheless use it in that context (right panel of Figure 7.4).

232

7. Model Assessment and Selection

Log-likelihood Loss

0-1 Loss

d
o
o
h

i
l

e
k

i
l
-
g
o
L

5
.
2

0
.
2

5
.
1

0
.
1

5
.
0

Train
Test
AIC

O
O
O

O
O
O

O
O
O

O
O
O

O
O
O

O
O
O

O
O

O

O

O

O

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

i

l

O
O

O

5
3
.
0

0
3
.
0

5
2
.
0

0
2
.
0

5
1
.
0

0
1
.
0

O
O
O

O
O
O

O

O
O

O
O

O

O

O
O

O

O

O

O

O

O

2

4

8

16

32

64 128

2

4

8

16

32

64 128

Number of Basis Functions

Number of Basis Functions

P

FIGURE 7.4. AIC used for model selection for the phoneme recogni-
function
tion example of Section 5.2.3. The logistic regression coeﬃcient
M
m=1 hm(f )θm is modeled as an expansion in M spline basis functions.
β(f ) =
In the left panel we see the AIC statistic used to estimate Errin using log-likeli-
hood loss. Included is an estimate of Err based on an independent test sample. It
does well except for the extremely over-parametrized case (M = 256 parameters
for N = 1000 observations). In the right panel the same is done for 0–1 loss.
Although the AIC formula does not strictly apply here, it does a reasonable job in
this case.

7.6 The Eﬀective Number of Parameters

The concept of “number of parameters” can be generalized, especially to
models where regularization is used in the ﬁtting. Suppose we stack the
outcomes y1, y2, . . . , yN into a vector y, and similarly for the predictions
ˆy. Then a linear ﬁtting method is one for which we can write

ˆy = Sy,

(7.31)

×

where S is an N
N matrix depending on the input vectors xi but not on
the yi. Linear ﬁtting methods include linear regression on the original fea-
tures or on a derived basis set, and smoothing methods that use quadratic
shrinkage, such as ridge regression and cubic smoothing splines. Then the
eﬀective number of parameters is deﬁned as

df(S) = trace(S),

(7.32)

the sum of the diagonal elements of S (also known as the eﬀective degrees-
of-freedom). Note that if S is an orthogonal-projection matrix onto a basis

 
7.7 The Bayesian Approach and BIC

233

set spanned by M features, then trace(S) = M . It turns out that trace(S) is
exactly the correct quantity to replace d as the number of parameters in the
Cp statistic (7.26). If y arises from an additive-error model Y = f (X) + ε
N
i=1 Cov(ˆyi, yi) = trace(S)σ2
with Var(ε) = σ2
ε ,
which motivates the more general deﬁnition

ε , then one can show that

P

df(ˆy) =

N
i=1 Cov(ˆyi, yi)
σ2
ε

P

(7.33)

(Exercises 7.4 and 7.5). Section 5.4.1 on page 153 gives some more intuition
for the deﬁnition df = trace(S) in the context of smoothing splines.

For models like neural networks, in which we minimize an error function
m, the eﬀective

R(w) with weight decay penalty (regularization) α
number of parameters has the form

m w2

df(α) =

M

m=1
X

θm
θm + α

,

P

(7.34)

where the θm are the eigenvalues of the Hessian matrix ∂2R(w)/∂w∂wT .
Expression (7.34) follows from (7.32) if we make a quadratic approximation
to the error function at the solution (Bishop, 1995).

7.7 The Bayesian Approach and BIC

The Bayesian information criterion (BIC), like AIC, is applicable in settings
where the ﬁtting is carried out by maximization of a log-likelihood. The
generic form of BIC is

BIC =

2

−

·

loglik + (log N )

d.

·

(7.35)

The BIC statistic (times 1/2) is also known as the Schwarz criterion (Schwarz,
1978).

Under the Gaussian model, assuming the variance σ2
ε , which is N
i(yi−

equals (up to a constant)
error loss. Hence we can write

ˆf (xi))2/σ2

·

ε is known,
err/σ2

2
loglik
·
ε for squared

−

BIC =

P
N
σ2
ε

err + (log N )

h

d
N

·

σ2
ε

.

i

(7.36)

Therefore BIC is proportional to AIC (Cp), with the factor 2 replaced
by log N . Assuming N > e2
7.4, BIC tends to penalize complex models
more heavily, giving preference to simpler models in selection. As with AIC,
σ2
ε is typically estimated by the mean squared error of a low-bias model.
For classiﬁcation problems, use of the multinomial log-likelihood leads to a
similar relationship with the AIC, using cross-entropy as the error measure.

≈

234

7. Model Assessment and Selection

Note however that the misclassiﬁcation error measure does not arise in the
BIC context, since it does not correspond to the log-likelihood of the data
under any probability model.

Despite its similarity with AIC, BIC is motivated in quite a diﬀerent
way. It arises in the Bayesian approach to model selection, which we now
describe.

Suppose we have a set of candidate models

Mm, m = 1, . . . , M and
corresponding model parameters θm, and we wish to choose a best model
from among them. Assuming we have a prior distribution Pr(θm|Mm) for
Mm, the posterior probability of a given
the parameters of each model
model is

Pr(

Z)

Mm|

Pr(

Pr(

Mm)
Mm)

·

·

∝

∝

Pr(Z

|Mm)
θm,

Pr(Z

|

Z

(7.37)

Mm)Pr(θm|Mm)dθm,

N
1 . To compare two models

where Z represents the training data
Mm and

xi, yi}
{
Mℓ, we form the posterior odds
Z)
Z)

Mm)
Mℓ) ·
If the odds are greater than one we choose model m, otherwise we choose
model ℓ. The rightmost quantity

|Mm)
|Mℓ)

Mm|
Mℓ|

Pr(Z
Pr(Z

Pr(
Pr(

Pr(
Pr(

(7.38)

=

.

BF(Z) =

Pr(Z
Pr(Z

|Mm)
|Mℓ)

(7.39)

is called the Bayes factor, the contribution of the data toward the posterior
odds.

Typically we assume that the prior over models is uniform, so that
Mm) is constant. We need some way of approximating Pr(Z
|Mm).
Pr(
A so-called Laplace approximation to the integral followed by some other
simpliﬁcations (Ripley, 1996, page 64) to (7.37) gives

log Pr(Z

|Mm) = log Pr(Z

|

ˆθm,

Mm)

−

dm
2 ·

log N + O(1).

(7.40)

Here ˆθm is a maximum likelihood estimate and dm is the number of free
parameters in model

Mm. If we deﬁne our loss function to be
ˆθm,

2 log Pr(Z

Mm),

|

−

this is equivalent to the BIC criterion of equation (7.35).

Therefore, choosing the model with minimum BIC is equivalent to choos-
ing the model with largest (approximate) posterior probability. But this
framework gives us more. If we compute the BIC criterion for a set of M ,

7.8 Minimum Description Length

235

models, giving BICm, m = 1, 2, . . . , M , then we can estimate the posterior
probability of each model

Mm as
e− 1
M
ℓ=1 e− 1

2 ·BICm

2 ·BICℓ

.

(7.41)

Thus we can estimate not only the best model, but also assess the relative
merits of the models considered.

P

For model selection purposes, there is no clear choice between AIC and
BIC. BIC is asymptotically consistent as a selection criterion. What this
means is that given a family of models, including the true model, the prob-
ability that BIC will select the correct model approaches one as the sample
. This is not the case for AIC, which tends to choose models
size N
which are too complex as N
. On the other hand, for ﬁnite samples,
BIC often chooses models that are too simple, because of its heavy penalty
on complexity.

→ ∞

→ ∞

7.8 Minimum Description Length

The minimum description length (MDL) approach gives a selection cri-
terion formally identical to the BIC approach, but is motivated from an
optimal coding viewpoint. We ﬁrst review the theory of coding for data
compression, and then apply it to model selection.

We think of our datum z as a message that we want to encode and
send to someone else (the “receiver”). We think of our model as a way of
encoding the datum, and will choose the most parsimonious model, that is
the shortest code, for the transmission.

Suppose ﬁrst that the possible messages we might want to transmit are
z1, z2, . . . , zm. Our code uses a ﬁnite alphabet of length A: for example, we
of length A = 2. Here is an example with
might use a binary code
four possible messages and a binary coding:

0, 1
}
{

Message
Code

z1
0

z2
10

z3
110

z4
111

(7.42)

This code is known as an instantaneous preﬁx code: no code is the pre-
ﬁx of any other, and the receiver (who knows all of the possible codes),
knows exactly when the message has been completely sent. We restrict our
discussion to such instantaneous preﬁx codes.

One could use the coding in (7.42) or we could permute the codes, for
example use codes 110, 10, 111, 0 for z1, z2, z3, z4. How do we decide which
to use? It depends on how often we will be sending each of the messages.
If, for example, we will be sending z1 most often, it makes sense to use the
shortest code 0 for z1. Using this kind of strategy—shorter codes for more
frequent messages—the average message length will be shorter.

236

7. Model Assessment and Selection

In general, if messages are sent with probabilities Pr(zi), i = 1, 2, . . . , 4,
a famous theorem due to Shannon says we should use code lengths li =

log2 Pr(zi) and the average message length satisﬁes

−

E(length)

≥ −

Pr(zi) log2 (Pr(zi)).

(7.43)

The right-hand side above is also called the entropy of the distribution
Pr(zi). The inequality is an equality when the probabilities satisfy pi =
A−li . In our example, if Pr(zi) = 1/2, 1/4, 1/8, 1/8, respectively, then the
coding shown in (7.42) is optimal and achieves the entropy lower bound.

X

In general the lower bound cannot be achieved, but procedures like the
Huﬀman coding scheme can get close to the bound. Note that with an
Pr(z) log2 Pr(z)dz.
inﬁnite set of messages, the entropy is replaced by

From this result we glean the following:

−

R

To transmit a random variable z having probability density func-
tion Pr(z), we require about

log2 Pr(z) bits of information.

−

We henceforth change notation from log2 Pr(z) to log Pr(z) = loge Pr(z);
this is for convenience, and just introduces an unimportant multiplicative
constant.

Now we apply this result to the problem of model selection. We have
a model M with parameters θ, and data Z = (X, y) consisting of both
inputs and outputs. Let the (conditional) probability of the outputs under
the model be Pr(y
θ, M, X), assume the receiver knows all of the inputs,
and we wish to transmit the outputs. Then the message length required to
transmit the outputs is

|

length =

log Pr(y

|

−

θ, M, X)

log Pr(θ

M ),

|

−

(7.44)

the log-probability of the target values given the inputs. The second term
is the average code length for transmitting the model parameters θ, while
the ﬁrst term is the average code length for transmitting the discrepancy
between the model and actual target values. For example suppose we have
a single target y with y
N (0, 1) and no input
(for simplicity). Then the message length is

N (θ, σ2), parameter θ

∼

∼

length = constant + log σ +

(y

θ)2
2σ2 +
−

θ2
2

.

(7.45)

Note that the smaller σ is, the shorter on average is the message length,
since y is more concentrated around θ.

The MDL principle says that we should choose the model that mini-
mizes (7.44). We recognize (7.44) as the (negative) log-posterior distribu-
tion, and hence minimizing description length is equivalent to maximizing
posterior probability. Hence the BIC criterion, derived as approximation to
log-posterior probability, can also be viewed as a device for (approximate)
model choice by minimum description length.

7.9 Vapnik–Chervonenkis Dimension

237

)
x

·

0
5
(
n
i
s

0
.
1

0
.
0

0
.
1
-

0.0

0.2

0.4

0.6

0.8

1.0

x

FIGURE 7.5. The solid curve is the function sin(50x) for x
[0, 1]. The green
(solid) and blue (hollow) points illustrate how the associated indicator function
I(sin(αx) > 0) can shatter (separate) an arbitrarily large number of points by
choosing an appropriately high frequency α.

∈

Note that we have ignored the precision with which a random variable
z is coded. With a ﬁnite code length we cannot code a continuous variable
exactly. However, if we code z within a tolerance δz, the message length
needed is the log of the probability in the interval [z, z+δz] which is well ap-
proximated by δzPr(z) if δz is small. Since log δzPr(z) = log δz + log Pr(z),
this means we can just ignore the constant log δz and use log Pr(z) as our
measure of message length, as we did above.

The preceding view of MDL for model selection says that we should
choose the model with highest posterior probability. However, many Bayes-
ians would instead do inference by sampling from the posterior distribution.

7.9 Vapnik–Chervonenkis Dimension

A diﬃculty in using estimates of in-sample error is the need to specify the
number of parameters (or the complexity) d used in the ﬁt. Although the
eﬀective number of parameters introduced in Section 7.6 is useful for some
nonlinear models, it is not fully general. The Vapnik–Chervonenkis (VC)
theory provides such a general measure of complexity, and gives associated
bounds on the optimism. Here we give a brief review of this theory.

}

∈

f (x, α)
{

Suppose we have a class of functions

indexed by a parameter
IRp. Assume for now that f is an indicator function,
vector α, with x
that is, takes the values 0 or 1. If α = (α0, α1) and f is the linear indi-
cator function I(α0 + αT
1 x > 0), then it seems reasonable to say that the
complexity of the class f is the number of parameters p + 1. But what
IR? The
about f (x, α) = I(sin α
function sin(50
x) is shown in Figure 7.5. This is a very wiggly function
that gets even rougher as the frequency α increases, but it has only one
parameter: despite this, it doesn’t seem reasonable to conclude that it has
less complexity than the linear indicator function I(α0 + α1x) in p = 1
dimension.

x) where α is any real number and x

∈

·

·

238

7. Model Assessment and Selection

FIGURE 7.6. The ﬁrst three panels show that the class of lines in the plane
can shatter three points. The last panel shows that this class cannot shatter four
points, as no line will put the hollow points on one side and the solid points on
the other. Hence the VC dimension of the class of straight lines in the plane is
three. Note that a class of nonlinear curves could shatter four points, and hence
has VC dimension greater than three.

The Vapnik–Chervonenkis dimension is a way of measuring the com-
plexity of a class of functions by assessing how wiggly its members can
be.

The VC dimension of the class
is deﬁned to be the
largest number of points (in some conﬁguration) that can be
shattered by members of

f (x, α)
{

}

f (x, α)
{

.
}

A set of points is said to be shattered by a class of functions if, no matter
how we assign a binary label to each point, a member of the class can
perfectly separate them.

Figure 7.6 shows that the VC dimension of linear indicator functions
in the plane is 3 but not 4, since no four points can be shattered by a
set of lines. In general, a linear indicator function in p dimensions has VC
dimension p + 1, which is also the number of free parameters. On the other
hand, it can be shown that the family sin(αx) has inﬁnite VC dimension,
as Figure 7.5 suggests. By appropriate choice of α, any set of points can be
shattered by this class (Exercise 7.8).

So far we have discussed the VC dimension only of indicator functions,
but this can be extended to real-valued functions. The VC dimension of a
is deﬁned to be the VC dimension
class of real-valued functions
of the indicator class
, where β takes values over the
}
range of g.

g(x, α)
{
I(g(x, α)
{

}
β > 0)

−

One can use the VC dimension in constructing an estimate of (extra-
sample) prediction error; diﬀerent types of results are available. Using the
concept of VC dimension, one can prove results about the optimism of the
training error when using a class of functions. An example of such a result is
the following. If we ﬁt N training points using a class of functions
having VC dimension h, then with probability at least 1

}
η over training

f (x, α)
{

−

7.9 Vapnik–Chervonenkis Dimension

239

sets:

ErrT ≤
ErrT ≤

1 +

ǫ
2
err
c√ǫ)+

(cid:16)

err +

(1

−

4

·

1 +

err
ǫ

(cid:17)
(regression)

r

(binary classiﬁcation)

(7.46)

log (η/4)

,

−

where ǫ = a1
and 0 < a1 ≤

h[log (a2N/h) + 1]

N
2

4, 0 < a2 ≤
These bounds hold simultaneously for all members f (x, α), and are taken
from Cherkassky and Mulier (2007, pages 116–118). They recommend the
value c = 1. For regression they suggest a1 = a2 = 1, and for classiﬁcation
they make no recommendation, with a1 = 4 and a2 = 2 corresponding
to worst-case scenarios. They also give an alternative practical bound for
regression

ErrT ≤

err

1

ρ

−

− r

ρ log ρ +

log N
2N !

(7.47)

+

−1

with ρ = h
N , which is free of tuning constants. The bounds suggest that the
optimism increases with h and decreases with N in qualitative agreement
with the AIC correction d/N given in (7.24). However, the results in (7.46)
are stronger: rather than giving the expected optimism for each ﬁxed func-
tion f (x, α), they give probabilistic upper bounds for all functions f (x, α),
and hence allow for searching over the class.

Vapnik’s structural risk minimization (SRM) approach ﬁts a nested se-
, and then

quence of models of increasing VC dimensions h1 < h2 <
· · ·
chooses the model with the smallest value of the upper bound.

We note that upper bounds like the ones in (7.46) are often very loose,
but that doesn’t rule them out as good criteria for model selection, where
the relative (not absolute) size of the test error is important. The main
drawback of this approach is the diﬃculty in calculating the VC dimension
of a class of functions. Often only a crude upper bound for VC dimension
is obtainable, and this may not be adequate. An example in which the
structural risk minimization program can be successfully carried out is the
support vector classiﬁer, discussed in Section 12.2.

7.9.1 Example (Continued)

Figure 7.7 shows the results when AIC, BIC and SRM are used to select
the model size for the examples of Figure 7.3. For the examples labeled KNN,
the model index α refers to neighborhood size, while for those labeled REG α
refers to subset size. Using each selection method (e.g., AIC) we estimated
the best model ˆα and found its true prediction error ErrT (ˆα) on a test
set. For the same training set we computed the prediction error of the best

 
240

7. Model Assessment and Selection

AIC

t
s
e
B

r
e
v
O
e
s
a
e
r
c
n
I

%

t
s
e
B

r
e
v
O
e
s
a
e
r
c
n
I

%

t
s
e
B

r
e
v
O
e
s
a
e
r
c
n
I

%

0
0
1

0
8

0
6

0
4

0
2

0

0
0
1

0
8

0
6

0
4

0
2

0

0
0
1

0
8

0
6

0
4

0
2

0

reg/KNN

reg/linear

class/KNN

class/linear

BIC

reg/KNN

reg/linear

class/KNN

class/linear

SRM

reg/KNN

reg/linear

class/KNN

class/linear

×

[ErrT ( ˆα)

show the distribution of

FIGURE 7.7. Boxplots
error
100
minα ErrT (α)] over the four
scenarios of Figure 7.3. This is the error in using the chosen model relative to
the best model. There are 100 training sets each of size 80 represented in each
boxplot, with the errors computed on test sets of size 10, 000.

minα ErrT (α)]/[maxα ErrT (α)

relative

the

−

−

 
 
 
 
 
 
 
 
 
and worst possible model choices: minα ErrT (α) and maxα ErrT (α). The
boxplots show the distribution of the quantity

7.10 Cross-Validation

241

100

×

ErrT (ˆα)
−
maxα ErrT (α)

minα ErrT (α)

minα ErrT (α)

−

,

which represents the error in using the chosen model relative to the best
model. For linear regression the model complexity was measured by the
number of features; as mentioned in Section 7.5, this underestimates the
df, since it does not charge for the search for the best model of that size.
This was also used for the VC dimension of the linear classiﬁer. For k-
nearest neighbors, we used the quantity N/k. Under an additive-error re-
gression model, this can be justiﬁed as the exact eﬀective degrees of free-
dom (Exercise 7.6); we do not know if it corresponds to the VC dimen-
sion. We used a1 = a2 = 1 for the constants in (7.46); the results for SRM
changed with diﬀerent constants, and this choice gave the most favorable re-
sults. We repeated the SRM selection using the alternative practical bound
(7.47), and got almost identical results. For misclassiﬁcation error we used
ˆσε
err(α) for the least restrictive model (k = 5 for KNN,
since k = 1 results in zero training error). The AIC criterion seems to work
well in all four scenarios, despite the lack of theoretical support with 0–1
loss. BIC does nearly as well, while the performance of SRM is mixed.

2 = [N/(N

d)]

−

·

7.10 Cross-Validation

Probably the simplest and most widely used method for estimating predic-
tion error is cross-validation. This method directly estimates the expected
extra-sample error Err = E[L(Y, ˆf (X))], the average generalization error
when the method ˆf (X) is applied to an independent test sample from the
joint distribution of X and Y . As mentioned earlier, we might hope that
cross-validation estimates the conditional error, with the training set
T
held ﬁxed. But as we will see in Section 7.12, cross-validation typically
estimates well only the expected prediction error.

7.10.1 K-Fold Cross-Validation

Ideally, if we had enough data, we would set aside a validation set and use
it to assess the performance of our prediction model. Since data are often
scarce, this is usually not possible. To ﬁnesse the problem, K-fold cross-
validation uses part of the available data to ﬁt the model, and a diﬀerent
part to test it. We split the data into K roughly equal-sized parts; for
example, when K = 5, the scenario looks like this:

242

7. Model Assessment and Selection

1

2

3

4

5

Train

Train

Validation

Train

Train

For the kth part (third above), we ﬁt the model to the other K

1 parts
of the data, and calculate the prediction error of the ﬁtted model when
predicting the kth part of the data. We do this for k = 1, 2, . . . , K and
combine the K estimates of prediction error.

−

Here are more details. Let κ :

be an indexing
function that indicates the partition to which observation i is allocated by
the randomization. Denote by ˆf −k(x) the ﬁtted function, computed with
the kth part of the data removed. Then the cross-validation estimate of
prediction error is

1, . . . , N
{

1, . . . , K

} 7→ {

}

CV( ˆf ) =

1
N

N

i=1
X

L(yi, ˆf −κ(i)(xi)).

(7.48)

Typical choices of K are 5 or 10 (see below). The case K = N is known
as leave-one-out cross-validation. In this case κ(i) = i, and for the ith
observation the ﬁt is computed using all the data except the ith.

Given a set of models f (x, α) indexed by a tuning parameter α, denote
by ˆf −k(x, α) the αth model ﬁt with the kth part of the data removed. Then
for this set of models we deﬁne

CV( ˆf , α) =

1
N

N

i=1
X

L(yi, ˆf −κ(i)(xi, α)).

(7.49)

The function CV( ˆf , α) provides an estimate of the test error curve, and we
ﬁnd the tuning parameter ˆα that minimizes it. Our ﬁnal chosen model is
f (x, ˆα), which we then ﬁt to all the data.

It is interesting to wonder about what quantity K-fold cross-validation
estimates. With K = 5 or 10, we might guess that it estimates the ex-
pected error Err, since the training sets in each fold are quite diﬀerent
from the original training set. On the other hand, if K = N we might
guess that cross-validation estimates the conditional error ErrT . It turns
out that cross-validation only estimates eﬀectively the average error Err,
as discussed in Section 7.12.

What value should we choose for K? With K = N , the cross-validation
estimator is approximately unbiased for the true (expected) prediction er-
ror, but can have high variance because the N “training sets” are so similar
to one another. The computational burden is also considerable, requiring
N applications of the learning method. In certain special problems, this
computation can be done quickly—see Exercises 7.3 and 5.13.

7.10 Cross-Validation

243

8
.
0

6
.
0

r
r

E
-
1

4
.
0

2
.
0

0
.
0

0

50

100
Size of Training Set

150

200

−

FIGURE 7.8. Hypothetical learning curve for a classiﬁer on a given task: a
Err versus the size of the training set N . With a dataset of 200
plot of 1
observations, 5-fold cross-validation would use training sets of size 160, which
would behave much like the full set. However, with a dataset of 50 observations
ﬁvefold cross-validation would use training sets of size 40, and this would result
in a considerable overestimate of prediction error.

−

On the other hand, with K = 5 say, cross-validation has lower variance.
But bias could be a problem, depending on how the performance of the
learning method varies with the size of the training set. Figure 7.8 shows
a hypothetical “learning curve” for a classiﬁer on a given task, a plot of
1
Err versus the size of the training set N . The performance of the
classiﬁer improves as the training set size increases to 100 observations;
increasing the number further to 200 brings only a small beneﬁt. If our
training set had 200 observations, ﬁvefold cross-validation would estimate
the performance of our classiﬁer over training sets of size 160, which from
Figure 7.8 is virtually the same as the performance for training set size
200. Thus cross-validation would not suﬀer from much bias. However if the
training set had 50 observations, ﬁvefold cross-validation would estimate
the performance of our classiﬁer over training sets of size 40, and from the
ﬁgure that would be an underestimate of 1
Err. Hence as an estimate of
−
Err, cross-validation would be biased upward.

To summarize, if the learning curve has a considerable slope at the given
training set size, ﬁve- or tenfold cross-validation will overestimate the true
prediction error. Whether this bias is a drawback in practice depends on
the objective. On the other hand, leave-one-out cross-validation has low
bias but can have high variance. Overall, ﬁve- or tenfold cross-validation
are recommended as a good compromise: see Breiman and Spector (1992)
and Kohavi (1995).

Figure 7.9 shows the prediction error and tenfold cross-validation curve
estimated from a single training set, from the scenario in the bottom right
panel of Figure 7.3. This is a two-class classiﬁcation problem, using a lin-

244

7. Model Assessment and Selection

r
o
r
r

E
n
o

i
t

a
c
i
f
i
s
s
a
c
s
M

l

i

•

•

•

•

• •
•

•

6
0

.

5

.

0

4
0

.

3
0

.

2

.

0

1

.

0

0
0

.

•
•

• •
•
•

•
•

5

•

•
• • • • • • •

• • • •
• • • • • • • • • • •

10

15

20

Subset Size p

FIGURE 7.9. Prediction error (orange) and tenfold cross-validation curve
(blue) estimated from a single training set, from the scenario in the bottom right
panel of Figure 7.3.

ear model with best subsets regression of subset size p. Standard error bars
are shown, which are the standard errors of the individual misclassiﬁcation
error rates for each of the ten parts. Both curves have minima at p = 10,
although the CV curve is rather ﬂat beyond 10. Often a “one-standard
error” rule is used with cross-validation, in which we choose the most par-
simonious model whose error is no more than one standard error above
the error of the best model. Here it looks like a model with about p = 9
predictors would be chosen, while the true model uses p = 10.

Generalized cross-validation provides a convenient approximation to leave-
one out cross-validation, for linear ﬁtting under squared-error loss. As de-
ﬁned in Section 7.6, a linear ﬁtting method is one for which we can write

Now for many linear ﬁtting methods,

ˆy = Sy.

1
N

N

i=1
X

[yi −

ˆf −i(xi)]2 =

1
N

N

i=1h
X

ˆf (xi)
Sii

yi −
1
−

2

,

i

(7.50)

(7.51)

where Sii is the ith diagonal element of S (see Exercise 7.3). The GCV
approximation is

GCV( ˆf ) =

1
N

N

1

i=1 "
X

ˆf (xi)
yi −
trace(S)/N #
−

2

.

(7.52)

 
The quantity trace(S) is the eﬀective number of parameters, as deﬁned in
Section 7.6.

7.10 Cross-Validation

245

GCV can have a computational advantage in some settings, where the
trace of S can be computed more easily than the individual elements Sii.
In smoothing problems, GCV can also alleviate the tendency of cross-
validation to undersmooth. The similarity between GCV and AIC can be
x)2
seen from the approximation 1/(1

1 + 2x (Exercise 7.7).

−

≈

7.10.2 The Wrong and Right Way to Do Cross-validation

Consider a classiﬁcation problem with a large number of predictors, as may
arise, for example, in genomic or proteomic applications. A typical strategy
for analysis might be as follows:

1. Screen the predictors: ﬁnd a subset of “good” predictors that show

fairly strong (univariate) correlation with the class labels

2. Using just this subset of predictors, build a multivariate classiﬁer.

3. Use cross-validation to estimate the unknown tuning parameters and

to estimate the prediction error of the ﬁnal model.

Is this a correct application of cross-validation? Consider a scenario with
N = 50 samples in two equal-sized classes, and p = 5000 quantitative
predictors (standard Gaussian) that are independent of the class labels.
The true (test) error rate of any classiﬁer is 50%. We carried out the above
recipe, choosing in step (1) the 100 predictors having highest correlation
with the class labels, and then using a 1-nearest neighbor classiﬁer, based
on just these 100 predictors, in step (2). Over 50 simulations from this
setting, the average CV error rate was 3%. This is far lower than the true
error rate of 50%.

What has happened? The problem is that the predictors have an unfair
advantage, as they were chosen in step (1) on the basis of all of the samples.
Leaving samples out after the variables have been selected does not cor-
rectly mimic the application of the classiﬁer to a completely independent
test set, since these predictors “have already seen” the left out samples.

Figure 7.10 (top panel) illustrates the problem. We selected the 100 pre-
dictors having largest correlation with the class labels over all 50 samples.
Then we chose a random set of 10 samples, as we would do in ﬁve-fold cross-
validation, and computed the correlations of the pre-selected 100 predictors
with the class labels over just these 10 samples (top panel). We see that
the correlations average about 0.28, rather than 0, as one might expect.
Here is the correct way to carry out cross-validation in this example:

1. Divide the samples into K cross-validation folds (groups) at random.

2. For each fold k = 1, 2, . . . , K

246

7. Model Assessment and Selection

Wrong way

y
c
n
e
u
q
e
r
F

y
c
n
e
u
q
e
r
F

0
3

0
2

0
1

0

0
3

0
2

0
1

0

−1.0

−0.5

0.0

0.5

1.0

Correlations of Selected Predictors with Outcome

Right way

−1.0

−0.5

0.0

0.5

1.0

Correlations of Selected Predictors with Outcome

FIGURE 7.10. Cross-validation the wrong and right way: histograms shows the
correlation of class labels, in 10 randomly chosen samples, with the 100 predic-
tors chosen using the incorrect (upper red) and correct (lower green) versions of
cross-validation.

(a) Find a subset of “good” predictors that show fairly strong (uni-
variate) correlation with the class labels, using all of the samples
except those in fold k.

(b) Using just this subset of predictors, build a multivariate classi-

ﬁer, using all of the samples except those in fold k.

(c) Use the classiﬁer to predict the class labels for the samples in

fold k.

The error estimates from step 2(c) are then accumulated over all K folds, to
produce the cross-validation estimate of prediction error. The lower panel
of Figure 7.10 shows the correlations of class labels with the 100 predictors
chosen in step 2(a) of the correct procedure, over the samples in a typical
fold k. We see that they average about zero, as they should.

In general, with a multistep modeling procedure, cross-validation must
be applied to the entire sequence of modeling steps. In particular, samples
must be “left out” before any selection or ﬁltering steps are applied. There
is one qualiﬁcation: initial unsupervised screening steps can be done be-
fore samples are left out. For example, we could select the 1000 predictors

7.10 Cross-Validation

247

with highest variance across all 50 samples, before starting cross-validation.
Since this ﬁltering does not involve the class labels, it does not give the
predictors an unfair advantage.

While this point may seem obvious to the reader, we have seen this
blunder committed many times in published papers in top rank journals.
With the large numbers of predictors that are so common in genomic and
other areas, the potential consequences of this error have also increased
dramatically; see Ambroise and McLachlan (2002) for a detailed discussion
of this issue.

7.10.3 Does Cross-Validation Really Work?

We once again examine the behavior of cross-validation in a high-dimensional
classiﬁcation problem. Consider a scenario with N = 20 samples in two
equal-sized classes, and p = 500 quantitative predictors that are indepen-
dent of the class labels. Once again, the true error rate of any classiﬁer is
50%. Consider a simple univariate classiﬁer: a single split that minimizes
the misclassiﬁcation error (a “stump”). Stumps are trees with a single split,
and are used in boosting methods (Chapter 10). A simple argument sug-
gests that cross-validation will not work properly in this setting2:

Fitting to the entire training set, we will ﬁnd a predictor that
splits the data very well. If we do 5-fold cross-validation, this
same predictor should split any 4/5ths and 1/5th of the data
well too, and hence its cross-validation error will be small (much
less than 50%.) Thus CV does not give an accurate estimate of
error.

To investigate whether this argument is correct, Figure 7.11 shows the
result of a simulation from this setting. There are 500 predictors and 20
samples, in each of two equal-sized classes, with all predictors having a
standard Gaussian distribution. The panel in the top left shows the number
of training errors for each of the 500 stumps ﬁt to the training data. We
have marked in color the six predictors yielding the fewest errors. In the top
right panel, the training errors are shown for stumps ﬁt to a random 4/5ths
partition of the data (16 samples), and tested on the remaining 1/5th (four
samples). The colored points indicate the same predictors marked in the
top left panel. We see that the stump for the blue predictor (whose stump
was the best in the top left panel), makes two out of four test errors (50%),
and is no better than random.

What has happened? The preceding argument has ignored the fact that
in cross-validation, the model must be completely retrained for each fold

2This argument was made to us by a scientist at a proteomics lab meeting, and led

to material in this section.

248

7. Model Assessment and Selection

t
e
S
g
n
n
a
r
T

i

i

l
l

u
F
n
o

r
o
r
r

E

l

e
b
a
L

s
s
a
C

l

9

8

7

6

5

4

3

2

1

0

5
/
1

n
o

r
o
r
r

E

4

3

2

1

0

0

100

200

300

400

500

1

2

3

4

5

6

7

8

Predictor

Error on 4/5

full
4/5

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

−1

0

1

2

Predictor 436 (blue)

CV Errors

FIGURE 7.11. Simulation study to investigate the performance of cross vali-
dation in a high-dimensional problem where the predictors are independent of the
class labels. The top-left panel shows the number of errors made by individual
stump classiﬁers on the full training set (20 observations). The top right panel
shows the errors made by individual stumps trained on a random split of the
dataset into 4/5ths (16 observations) and tested on the remaining 1/5th (4 ob-
servations). The best performers are depicted by colored dots in each panel. The
bottom left panel shows the eﬀect of re-estimating the split point in each fold: the
colored points correspond to the four samples in the 4/5ths validation set. The
split point derived from the full dataset classiﬁes all four samples correctly, but
when the split point is re-estimated on the 4/5ths data (as it should be), it com-
mits two errors on the four validation samples. In the bottom right we see the
overall result of ﬁve-fold cross-validation applied to 50 simulated datasets. The
average error rate is about 50%, as it should be.

 
 
 
 
 
 
 
7.11 Bootstrap Methods

249

of the process. In the present example, this means that the best predictor
and corresponding split point are found from 4/5ths of the data. The eﬀect
of predictor choice is seen in the top right panel. Since the class labels are
independent of the predictors, the performance of a stump on the 4/5ths
training data contains no information about its performance in the remain-
ing 1/5th. The eﬀect of the choice of split point is shown in the bottom left
panel. Here we see the data for predictor 436, corresponding to the blue
dot in the top left plot. The colored points indicate the 1/5th data, while
the remaining points belong to the 4/5ths. The optimal split points for this
predictor based on both the full training set and 4/5ths data are indicated.
The split based on the full data makes no errors on the 1/5ths data. But
cross-validation must base its split on the 4/5ths data, and this incurs two
errors out of four samples.

The results of applying ﬁve-fold cross-validation to each of 50 simulated
datasets is shown in the bottom right panel. As we would hope, the average
cross-validation error is around 50%, which is the true expected prediction
error for this classiﬁer. Hence cross-validation has behaved as it should.
On the other hand, there is considerable variability in the error, underscor-
ing the importance of reporting the estimated standard error of the CV
estimate. See Exercise 7.10 for another variation of this problem.

7.11 Bootstrap Methods

The bootstrap is a general tool for assessing statistical accuracy. First we
describe the bootstrap in general, and then show how it can be used to
estimate extra-sample prediction error. As with cross-validation, the boot-
strap seeks to estimate the conditional error ErrT , but typically estimates
well only the expected prediction error Err.

Suppose we have a model ﬁt to a set of training data. We denote the
training set by Z = (z1, z2, . . . , zN ) where zi = (xi, yi). The basic idea is
to randomly draw datasets with replacement from the training data, each
sample the same size as the original training set. This is done B times
(B = 100 say), producing B bootstrap datasets, as shown in Figure 7.12.
Then we reﬁt the model to each of the bootstrap datasets, and examine
the behavior of the ﬁts over the B replications.

In the ﬁgure, S(Z) is any quantity computed from the data Z, for ex-
ample, the prediction at some input point. From the bootstrap sampling
we can estimate any aspect of the distribution of S(Z), for example, its
variance,

Var[S(Z)] =

d

1

−

1

B

B

Xb=1

(S(Z∗b)

¯S∗)2,

−

(7.53)

250

7. Model Assessment and Selection

S(Z∗1)

S(Z∗2)

S(Z∗B)

Z∗1

Z∗2

Z∗B

Bootstrap
replications

Bootstrap
samples

Z = (z1, z2, . . . , zN )

Training
sample

FIGURE 7.12. Schematic of the bootstrap process. We wish to assess the sta-
tistical accuracy of a quantity S(Z) computed from our dataset. B training sets
Z∗b, b = 1, . . . , B each of size N are drawn with replacement from the original
dataset. The quantity of interest S(Z) is computed from each bootstrap training
set, and the values S(Z∗1), . . . , S(Z∗B) are used to assess the statistical accuracy
of S(Z).

where ¯S∗ =
Var[S(Z)] can be thought of as a
Monte-Carlo estimate of the variance of S(Z) under sampling from the
empirical distribution function ˆF for the data (z1, z2, . . . , zN ).

b S(Z∗b)/B. Note that

d

P

How can we apply the bootstrap to estimate prediction error? One ap-
proach would be to ﬁt the model in question on a set of bootstrap samples,
and then keep track of how well it predicts the original training set. If
ˆf ∗b(xi) is the predicted value at xi, from the model ﬁtted to the bth boot-
strap dataset, our estimate is

Errboot =

1
B

1
N

B

N

L(yi, ˆf ∗b(xi)).

(7.54)

i=1
X

d

However, it is easy to see that

Xb=1
Errboot does not provide a good estimate in
general. The reason is that the bootstrap datasets are acting as the training
samples, while the original training set is acting as the test sample, and
these two samples have observations in common. This overlap can make
overﬁt predictions look unrealistically good, and is the reason that cross-
validation explicitly uses non-overlapping data for the training and test
samples. Consider for example a 1-nearest neighbor classiﬁer applied to a
two-class classiﬁcation problem with the same number of observations in

d

  
7.11 Bootstrap Methods

251

each class, in which the predictors and class labels are in fact independent.
Then the true error rate is 0.5. But the contributions to the bootstrap
estimate
Errboot will be zero unless the observation i does not appear in the
bootstrap sample b. In this latter case it will have the correct expectation
0.5. Now

d

Pr

observation i
{

∈

bootstrap sample b

= 1

−

}

1

−

1

(cid:16)
e−1

≈
= 0.632.

−

N

1
N

(cid:17)

(7.55)

Hence the expectation of
the correct error rate 0.5.

Errboot is about 0.5

×

0.368 = 0.184, far below

By mimicking cross-validation, a better bootstrap estimate can be ob-
tained. For each observation, we only keep track of predictions from boot-
strap samples not containing that observation. The leave-one-out bootstrap
estimate of prediction error is deﬁned by

d

(1)

Err

=

N

1
N

1
C −i

L(yi, ˆf ∗b(xi)).

(7.56)

|

|

|

d

C −i

i=1
X

| Xb∈C−i
Here C −i is the set of indices of the bootstrap samples b that do not contain
(1)

’s that are zero.

is the number of such samples. In computing

,
observation i, and
we either have to choose B large enough to ensure that all of the
are
greater than zero, or we can just leave out the terms in (7.56) corresponding
to

C −i
|
The leave-one out bootstrap solves the overﬁtting problem suﬀered by
Errboot, but has the training-set-size bias mentioned in the discussion of
cross-validation. The average number of distinct observations in each boot-
N , so its bias will roughly behave like that of
strap sample is about 0.632
d
twofold cross-validation. Thus if the learning curve has considerable slope
at sample size N/2, the leave-one out bootstrap will be biased upward as
an estimate of the true error.

|
d

C −i

Err

|

|

·

The “.632 estimator” is designed to alleviate this bias. It is deﬁned by

(.632)

Err

= .368

err + .632

·

(1)

.

Err

·

(7.57)

d

d

The derivation of the .632 estimator is complex; intuitively it pulls the
leave-one out bootstrap estimate down toward the training error rate, and
hence reduces its upward bias. The use of the constant .632 relates to (7.55).
The .632 estimator works well in “light ﬁtting” situations, but can break
down in overﬁt ones. Here is an example due to Breiman et al. (1984).
Suppose we have two equal-size classes, with the targets independent of
the class labels, and we apply a one-nearest neighbor rule. Then err = 0,

252

7. Model Assessment and Selection

(1)

(.632)

×

Err

= .632

= 0.5 and so

0.5 = .316. However, the true error

Err
rate is 0.5.
One can improve the .632 estimator by taking into account the amount
d
of overﬁtting. First we deﬁne γ to be the no-information error rate: this
is the error rate of our prediction rule if the inputs and class labels were
independent. An estimate of γ is obtained by evaluating the prediction rule
on all possible combinations of targets yi and predictors xi′

d

N

N

L(yi, ˆf (xi′ )).

(7.58)

ˆγ =

1
N 2

i=1
X

Xi′=1

For example, consider the dichotomous classiﬁcation problem: let ˆp1 be
the observed proportion of responses yi equaling 1, and let ˆq1 be the ob-
served proportion of predictions ˆf (xi′ ) equaling 1. Then

ˆγ = ˆp1(1

ˆq1) + (1

ˆp1)ˆq1.

−

−

(7.59)

With a rule like 1-nearest neighbors for which ˆq1 = ˆp1 the value of ˆγ is
ˆqℓ).
2ˆp1(1

ˆp1). The multi-category generalization of (7.59) is ˆγ =

−

Using this, the relative overﬁtting rate is deﬁned to be

ℓ ˆpℓ(1

−

P

(7.60)

ˆR =

(1)

−

Err
ˆγ
d

err

−
err

,

a quantity that ranges from 0 if there is no overﬁtting (
if the overﬁtting equals the no-information value ˆγ
the “.632+” estimator by

−

d

(1)

Err

= err) to 1
err. Finally, we deﬁne

(.632+)

Err

= (1

err + ˆw

with ˆw =

d

1

·

ˆw)
−
.632
.368 ˆR

.

−

(1)

Err

·

d

(7.61)

(1)

to

(.632)

Err

Err

The weight w ranges from .632 if ˆR = 0 to 1 if ˆR = 1, so
ranges from
. Again, the derivation of (7.61) is compli-
cated: roughly speaking, it produces a compromise between the leave-one-
out bootstrap and the training error rate that depends on the amount of
overﬁtting. For the 1-nearest-neighbor problem with class labels indepen-
dent of the inputs, ˆw = ˆR = 1, so
expectation of 0.5. In other problems with less overﬁtting,

, which has the correct

(.632+)

(.632+)

will

Err

Err

Err

Err

d

d

d

=

(1)

(.632+)

lie somewhere between err and

Err

.

d
(1)

d

d

d
7.11.1 Example (Continued)

Figure 7.13 shows the results of tenfold cross-validation and the .632+ boot-
strap estimate in the same four problems of Figures 7.7. As in that ﬁgure,

7.11 Bootstrap Methods

253

Cross−validation

t
s
e
B

r
e
v
O
e
s
a
e
r
c
n
I

%

t
s
e
B

r
e
v
O
e
s
a
e
r
c
n
I

%

0
0
1

0
8

0
6

0
4

0
2

0

0
0
1

0
8

0
6

0
4

0
2

0

reg/KNN

reg/linear

class/KNN

class/linear

Bootstrap

reg/KNN

reg/linear

class/KNN

class/linear

[Err ˆα

FIGURE 7.13. Boxplots
error
the
100
minα Err(α)] over the four scenar-
ios of Figure 7.3. This is the error in using the chosen model relative to the best
model. There are 100 training sets represented in each boxplot.

show the distribution of

minα Err(α)]/[maxα Err(α)

relative

−

−

·

Figure 7.13 shows boxplots of 100
−
minα Err(α)], the error in using the chosen model relative to the best model.
There are 100 diﬀerent training sets represented in each boxplot. Both mea-
sures perform well overall, perhaps the same or slightly worse than the AIC
in Figure 7.7.

minα Err(α)]/[maxα Err(α)

[Err ˆα −

·

Our conclusion is that for these particular problems and ﬁtting methods,
minimization of either AIC, cross-validation or bootstrap yields a model
fairly close to the best available. Note that for the purpose of model selec-
tion, any of the measures could be biased and it wouldn’t aﬀect things, as
long as the bias did not change the relative performance of the methods.
For example, the addition of a constant to any of the measures would not
change the resulting chosen model. However, for many adaptive, nonlinear
techniques (like trees), estimation of the eﬀective number of parameters is
very diﬃcult. This makes methods like AIC impractical and leaves us with
cross-validation or bootstrap as the methods of choice.

A diﬀerent question is: how well does each method estimate test error?
On the average the AIC criterion overestimated prediction error of its cho-

 
 
 
 
 
 
254

7. Model Assessment and Selection

sen model by 38%, 37%, 51%, and 30%, respectively, over the four scenarios,
with BIC performing similarly. In contrast, cross-validation overestimated
the error by 1%, 4%, 0%, and 4%, with the bootstrap doing about the
same. Hence the extra work involved in computing a cross-validation or
bootstrap measure is worthwhile, if an accurate estimate of test error is
required. With other ﬁtting methods like trees, cross-validation and boot-
strap can underestimate the true error by 10%, because the search for best
tree is strongly aﬀected by the validation set. In these situations only a
separate test set will provide an unbiased estimate of test error.

7.12 Conditional or Expected Test Error?

Figures 7.14 and 7.15 examine the question of whether cross-validation does
a good job in estimating ErrT , the error conditional on a given training set
(expression (7.15) on page 228), as opposed to the expected test error.
T
For each of 100 training sets generated from the “reg/linear” setting in
the top-right panel of Figure 7.3, Figure 7.14 shows the conditional error
curves ErrT as a function of subset size (top left). The next two panels show
10-fold and N -fold cross-validation, the latter also known as leave-one-out
(LOO). The thick red curve in each plot is the expected error Err, while
the thick black curves are the expected cross-validation curves. The lower
right panel shows how well cross-validation approximates the conditional
and expected error.

One might have expected N -fold CV to approximate ErrT well, since it
almost uses the full training sample to ﬁt a new test point. 10-fold CV, on
the other hand, might be expected to estimate Err well, since it averages
over somewhat diﬀerent training sets. From the ﬁgure it appears 10-fold
does a better job than N -fold in estimating ErrT , and estimates Err even
better. Indeed, the similarity of the two black curves with the red curve
suggests both CV curves are approximately unbiased for Err, with 10-fold
having less variance. Similar trends were reported by Efron (1983).

Figure 7.15 shows scatterplots of both 10-fold and N -fold cross-validation
error estimates versus the true conditional error for the 100 simulations.
Although the scatterplots do not indicate much correlation, the lower right
panel shows that for the most part the correlations are negative, a curi-
ous phenomenon that has been observed before. This negative correlation
explains why neither form of CV estimates ErrT well. The broken lines in
each plot are drawn at Err(p), the expected error for the best subset of
size p. We see again that both forms of CV are approximately unbiased for
expected error, but the variation in test error for diﬀerent training sets is
quite substantial.

Among the four experimental conditions in 7.3, this “reg/linear” scenario
showed the highest correlation between actual and predicted test error. This

7.12 Conditional or Expected Test Error?

255

Prediction Error

10−Fold CV Error

r
o
r
r

E

4
.
0

3
.
0

2
.
0

1
.
0

5

10

15

20

5

10

15

20

Subset Size p

Subset Size p

Leave−One−Out CV Error

Approximation Error

i

n
o
i
t
a
v
e
D
e
t
u
o
s
b
A
n
a
e
M

l

ET |CV10 −Err|
ET |CV10 −ErrT |
ET |CVN −ErrT |

5
4
0
.
0

5
3
0
.
0

5
2
0
.
0

5
1
0
.
0

5

10

15

20

5

10

15

20

Subset Size p

Subset Size p

r
o
r
r

E

r
o
r
r

E

4
.
0

3
.
0

2
.
0

1
.
0

4
.
0

3
.
0

2
.
0

1
.
0

FIGURE 7.14. Conditional prediction-error ErrT , 10-fold cross-validation, and
leave-one-out cross-validation curves for a 100 simulations from the top-right
panel in Figure 7.3. The thick red curve is the expected prediction error Err,
while the thick black curves are the expected CV curves ET CV10 and ET CVN .
The lower-right panel shows the mean absolute deviation of the CV curves from
the conditional error, ET
for K = 10 (blue) and K = N (green),
as well as from the expected error ET

(orange).

|
CV10

CVK

ErrT

−

|

|

Err
|

−

 
 
256

7. Model Assessment and Selection

0
4
.
0

0
3
.
0

0
2
.
0

0
1
0

.

0
4
0

.

0
3
0

.

0
2
0

.

0
1
0

.

r
o
r
r

E
V
C

r
o
r
r

E
V
C

Subset Size 1

Subset Size 5

0
4
.
0

0
3
.
0

0
2
.
0

0
1
0

.

r
o
r
r

E
V
C

0.10 0.15 0.20 0.25 0.30 0.35 0.40

0.10 0.15 0.20 0.25 0.30 0.35 0.40

Prediction Error

Prediction Error

Subset Size 10

n
o

i
t

l

a
e
r
r
o
C

2
0

.

0
0

.

.

2
0
−

.

4
0
−

.

6
0
−

Leave−one−out
10−Fold

0.10 0.15 0.20 0.25 0.30 0.35 0.40

5

10

15

20

Prediction Error

Subset Size

FIGURE 7.15. Plots of the CV estimates of error versus the true conditional
error for each of the 100 training sets, for the simulation setup in the top right
panel Figure 7.3. Both 10-fold and leave-one-out CV are depicted in diﬀerent
colors. The ﬁrst three panels correspond to diﬀerent subset sizes p, and vertical
and horizontal lines are drawn at Err(p). Although there appears to be little cor-
relation in these plots, we see in the lower right panel that for the most part the
correlation is negative.

 
 
 
Exercises

257

phenomenon also occurs for bootstrap estimates of error, and we would
guess, for any other estimate of conditional prediction error.

We conclude that estimation of test error for a particular training set is
not easy in general, given just the data from that same training set. Instead,
cross-validation and related methods may provide reasonable estimates of
the expected error Err.

Bibliographic Notes

Key references for cross-validation are Stone (1974), Stone (1977) and
Allen (1974). The AIC was proposed by Akaike (1973), while the BIC
was introduced by Schwarz (1978). Madigan and Raftery (1994) give an
overview of Bayesian model selection. The MDL criterion is due to Rissa-
nen (1983). Cover and Thomas (1991) contains a good description of coding
theory and complexity. VC dimension is described in Vapnik (1996). Stone
(1977) showed that the AIC and leave-one out cross-validation are asymp-
totically equivalent. Generalized cross-validation is described by Golub et
al. (1979) and Wahba (1980); a further discussion of the topic may be found
in the monograph by Wahba (1990). See also Hastie and Tibshirani (1990),
Chapter 3. The bootstrap is due to Efron (1979); see Efron and Tibshi-
rani (1993) for an overview. Efron (1983) proposes a number of bootstrap
estimates of prediction error, including the optimism and .632 estimates.
Efron (1986) compares CV, GCV and bootstrap estimates of error rates.
The use of cross-validation and the bootstrap for model selection is stud-
ied by Breiman and Spector (1992), Breiman (1992), Shao (1996), Zhang
(1993) and Kohavi (1995). The .632+ estimator was proposed by Efron
and Tibshirani (1997).

Cherkassky and Ma (2003) published a study on the performance of
SRM for model selection in regression, in response to our study of section
7.9.1. They complained that we had been unfair to SRM because had not
applied it properly. Our response can be found in the same issue of the
journal (Hastie et al. (2003)).

Exercises

Ex. 7.1 Derive the estimate of in-sample error (7.24).

Ex. 7.2 For 0–1 loss with Y

0, 1
}

and Pr(Y = 1
|

x0) = f (x0), show that

∈ {
= ˆG(x0)

Err(x0) = Pr(Y

= ErrB(x0) +

|

|
2f (x0)

X = x0)
1
|

−

Pr( ˆG(x0)

= G(x0)

|

X = x0),

(7.62)

6
6
258

7. Model Assessment and Selection

where ˆG(x) = I( ˆf (x) > 1
= G(x0)
and ErrB(x0) = Pr(Y
|
Using the approximation ˆf (x0)

2 ), G(x) = I(f (x) > 1

2 ) is the Bayes classiﬁer,
X = x0), the irreducible Bayes error at x0.

N (E ˆf (x0), Var( ˆf (x0)), show that

Pr( ˆG(x0)

= G(x0)

X = x0)

|

≈

In the above,

∼

Φ

sign( 1

2 −

f (x0))(E ˆf (x0)
Var( ˆf (x0))

1
2 )

−

!

. (7.63)

q

Φ(t) =

1
√2π

t

−∞

Z

exp(

−

t2/2)dt,

.

−

∞

−∞
2 −

We can think of sign( 1

the cumulative Gaussian distribution function. This is an increasing func-
tion, with value 0 at t =

and value 1 at t = +
f (x0))(E ˆf (x0)
1
2 ) as a kind of boundary-
bias term, as it depends on the true f (x0) only through which side of the
boundary ( 1
2 ) that it lies. Notice also that the bias and variance combine
in a multiplicative rather than additive fashion. If E ˆf (x0) is on the same
side of 1
2 as f (x0), then the bias is negative, and decreasing the variance
will decrease the misclassiﬁcation error. On the other hand, if E ˆf (x0) is
on the opposite side of 1
2 to f (x0), then the bias is positive and it pays to
increase the variance! Such an increase will improve the chance that ˆf (x0)
falls on the correct side of 1
2 (Friedman, 1997).

Ex. 7.3 Let ˆf = Sy be a linear smoothing of y.

(a) If Sii is the ith diagonal element of S, show that for S arising from least
squares projections and cubic smoothing splines, the cross-validated
residual can be written as

ˆf −i(xi) =

yi −

ˆf (xi)
Sii

yi −
1
−

.

(7.64)

(b) Use this result to show that

yi −
(c) Find general conditions on any smoother S to make result (7.64) hold.

yi −

| ≥ |

|

|

.

ˆf −i(xi)

ˆf (xi)

Ex. 7.4 Consider the in-sample prediction error (7.18) and the training
error err in the case of squared-error loss:

Errin =

err =

1
N

1
N

N

i=1
X
N

i=1
X

EY 0(Y 0

i −

ˆf (xi))2

ˆf (xi))2.

(yi −

6
6
 
Add and subtract f (xi) and E ˆf (xi) in each expression and expand. Hence
establish that the average optimism in the training error is

Exercises

259

2
N

N

i=1
X

Cov(ˆyi, yi),

as given in (7.21).

Ex. 7.5 For a linear smoother ˆy = Sy, show that

Cov(ˆyi, yi) = trace(S)σ2
ε ,

(7.65)

N

i=1
X

which justiﬁes its use as the eﬀective number of parameters.

Ex. 7.6 Show that for an additive-error model, the eﬀective degrees-of-
freedom for the k-nearest-neighbors regression ﬁt is N/k.

x)2
1+2x to expose the relationship
Ex. 7.7 Use the approximation 1/(1
between Cp/AIC (7.26) and GCV (7.52), the main diﬀerence being the
model used to estimate the noise variance σ2
ε .

≈

−

Ex. 7.8 Show that the set of functions
following points on the line:

I(sin(αx) > 0)
{

}

can shatter the

z1 = 10−1, . . . , zℓ = 10−ℓ,

(7.66)

for any ℓ. Hence the VC dimension of the class

I(sin(αx) > 0)
{

}

is inﬁnite.

Ex. 7.9 For the prostate data of Chapter 3, carry out a best-subset linear
regression analysis, as in Table 3.3 (third column from left). Compute the
AIC, BIC, ﬁve- and tenfold cross-validation, and bootstrap .632 estimates
of prediction error. Discuss the results.

Ex. 7.10 Referring to the example in Section 7.10.3, suppose instead that
all of the p predictors are binary, and hence there is no need to estimate
split points. The predictors are independent of the class labels as before.
Then if p is very large, we can probably ﬁnd a predictor that splits the
entire training data perfectly, and hence would split the validation data
(one-ﬁfth of data) perfectly as well. This predictor would therefore have
zero cross-validation error. Does this mean that cross-validation does not
provide a good estimate of test error in this situation? [This question was
suggested by Li Ma.]

260

7. Model Assessment and Selection

8
Model Inference and Averaging

This is page 261
Printer: Opaque this

8.1

Introduction

For most of this book, the ﬁtting (learning) of models has been achieved by
minimizing a sum of squares for regression, or by minimizing cross-entropy
for classiﬁcation. In fact, both of these minimizations are instances of the
maximum likelihood approach to ﬁtting.

In this chapter we provide a general exposition of the maximum likeli-
hood approach, as well as the Bayesian method for inference. The boot-
strap, introduced in Chapter 7, is discussed in this context, and its relation
to maximum likelihood and Bayes is described. Finally, we present some
related techniques for model averaging and improvement, including com-
mittee methods, bagging, stacking and bumping.

8.2 The Bootstrap and Maximum Likelihood

Methods

8.2.1 A Smoothing Example

The bootstrap method provides a direct computational way of assessing
uncertainty, by sampling from the training data. Here we illustrate the
bootstrap in a simple one-dimensional smoothing problem, and show its
connection to maximum likelihood.

262

8. Model Inference and Averaging

y

5

4

3

2

1

0

1
-

•

•
•

• ••
•
•
•
•

•
•

•

•

•

•
••••
•

• ••
•
•
••• •

•
•
••

•

•

•
••
••
•
•

•
••

•
• •

•

i

s
s
a
B
e
n

i
l

p
s
-
B

0

.

1

8

.

0

6
0

.

4
0

.

2
0

.

0
0

.

0.0

0.5

1.0

1.5

2.0

2.5

3.0

0.0

0.5

1.0

1.5

2.0

2.5

3.0

x

x

FIGURE 8.1. (Left panel): Data for smoothing example. (Right panel:) Set of
seven B-spline basis functions. The broken vertical lines indicate the placement
of the three knots.

Denote the training data by Z =

, with zi = (xi, yi),
i = 1, 2, . . . , N . Here xi is a one-dimensional input, and yi the outcome,
either continuous or categorical. As an example, consider the N = 50 data
points shown in the left panel of Figure 8.1.

z1, z2, . . . , zN }
{

Suppose we decide to ﬁt a cubic spline to the data, with three knots
placed at the quartiles of the X values. This is a seven-dimensional lin-
ear space of functions, and can be represented, for example, by a linear
expansion of B-spline basis functions (see Section 5.9.2):

7

µ(x) =

βjhj(x).

(8.1)

j=1
X
Here the hj(x), j = 1, 2, . . . , 7 are the seven functions shown in the right
panel of Figure 8.1. We can think of µ(x) as representing the conditional
mean E(Y

X = x).

|
Let H be the N

7 matrix with ijth element hj(xi). The usual estimate
of β, obtained by minimizing the squared error over the training set, is
given by

×

ˆβ = (HT H)−1HT y.

(8.2)

The corresponding ﬁt ˆµ(x) =
of Figure 8.2.

The estimated covariance matrix of ˆβ is

P

7
j=1

ˆβjhj(x) is shown in the top left panel

Var( ˆβ) = (HT H)−1 ˆσ2,

(8.3)

ˆµ(xi))2/N .
where we have estimated the noise variance by ˆσ2 =
d
Letting h(x)T = (h1(x), h2(x), . . . , h7(x)), the standard error of a predic-

i=1(yi −

N

P

 
8.2 The Bootstrap and Maximum Likelihood Methods

263

5

4

3

2

1

0

1
-

5

4

3

2

1

0

1
-

y

y

•

•
•

• ••
•
•
•
•

•
•

y

•

•

•

•
••••
•

• ••
•
•
••• •

•
•
••

•

•

•
••
••
•
•

•
••

•
• •

•

0.0

0.5

1.0

1.5

2.0

2.5

3.0

•

•
•

• ••
•
•
•
•

•
•

y

x

•

•

•

•
••
••
•
•

•
••

•
• •

•

•

•

•
••••
•

• ••
•
•
••• •

•
•
••

5

4

3

2

1

0

1
-

5

4

3

2

1

0

1
-

•

•
•

• ••
•
•
•
•

•
•

•

•

•

•
••••
•

• ••
•
•
••• •

•
•
••

•

•

•
••
••
•
•

•
••

•
• •

•

0.0

0.5

1.0

1.5

2.0

2.5

3.0

•

•
•

• ••
•
•
•
•

•
•

x

•

•

•

•
••
••
•
•

•
••

•
• •

•

•

•

•
••••
•

• ••
•
•
••• •

•
•
••

0.0

0.5

1.0

1.5

2.0

2.5

3.0

0.0

0.5

1.0

1.5

2.0

2.5

3.0

x

x

FIGURE 8.2. (Top left:) B-spline smooth of data. (Top right:) B-spline smooth
standard error bands. (Bottom left:) Ten bootstrap repli-
plus and minus 1.96
cates of the B-spline smooth. (Bottom right:) B-spline smooth with 95% standard
error bands computed from the bootstrap distribution.

×

264

8. Model Inference and Averaging

tion ˆµ(x) = h(x)T ˆβ is

se[ˆµ(x)] = [h(x)T (HT H)−1h(x)]

1

2 ˆσ.

(8.4)

b

In the top right panel of Figure 8.2 we have plotted ˆµ(x)

se[ˆµ(x)].
Since 1.96 is the 97.5% point of the standard normal distribution, these
represent approximate 100
2.5% = 95% pointwise conﬁdence bands
for µ(x).

1.96

±

−

×

b

2

·

Here is how we could apply the bootstrap in this example. We draw B
datasets each of size N = 50 with replacement from our training data, the
sampling unit being the pair zi = (xi, yi). To each bootstrap dataset Z∗
we ﬁt a cubic spline ˆµ∗(x); the ﬁts from ten such samples are shown in the
bottom left panel of Figure 8.2. Using B = 200 bootstrap samples, we can
form a 95% pointwise conﬁdence band from the percentiles at each x: we
200 = ﬁfth largest and smallest values at each x. These are
ﬁnd the 2.5%
plotted in the bottom right panel of Figure 8.2. The bands look similar to
those in the top right, being a little wider at the endpoints.

×

There is actually a close connection between the least squares estimates
(8.2) and (8.3), the bootstrap, and maximum likelihood. Suppose we further
assume that the model errors are Gaussian,

Y = µ(X) + ε; ε
7

∼

N (0, σ2),

µ(x) =

βjhj(x).

(8.5)

j=1
X

The bootstrap method described above, in which we sample with re-
placement from the training data, is called the nonparametric bootstrap.
This really means that the method is “model-free,” since it uses the raw
data, not a speciﬁc parametric model, to generate new datasets. Consider
a variation of the bootstrap, called the parametric bootstrap, in which we
simulate new responses by adding Gaussian noise to the predicted values:

i = ˆµ(xi) + ε∗
y∗
i ;

ε∗
i ∼

N (0, ˆσ2);

i = 1, 2, . . . , N.

(8.6)

This process is repeated B times, where B = 200 say. The resulting boot-
strap datasets have the form (x1, y∗
N ) and we recompute the
B-spline smooth on each. The conﬁdence bands from this method will ex-
actly equal the least squares bands in the top right panel, as the number of
bootstrap samples goes to inﬁnity. A function estimated from a bootstrap
sample y∗ is given by ˆµ∗(x) = h(x)T (HT H)−1HT y∗, and has distribution

1), . . . , (xN , y∗

ˆµ∗(x)

∼

N (ˆµ(x), h(x)T (HT H)−1h(x)ˆσ2).

(8.7)

Notice that the mean of this distribution is the least squares estimate, and
the standard deviation is the same as the approximate formula (8.4).

8.2 The Bootstrap and Maximum Likelihood Methods

265

8.2.2 Maximum Likelihood Inference

It turns out that the parametric bootstrap agrees with least squares in the
previous example because the model (8.5) has additive Gaussian errors. In
general, the parametric bootstrap agrees not with least squares but with
maximum likelihood, which we now review.

We begin by specifying a probability density or probability mass function

for our observations

zi ∼

gθ(z).

(8.8)

In this expression θ represents one or more unknown parameters that gov-
ern the distribution of Z. This is called a parametric model for Z. As an
example, if Z has a normal distribution with mean µ and variance σ2, then

and

θ = (µ, σ2),

gθ(z) =

1
√2πσ

e− 1

2 (z−µ)2/σ2

.

Maximum likelihood is based on the likelihood function, given by

N

L(θ; Z) =

gθ(zi),

(8.9)

(8.10)

(8.11)

i=1
Y
the probability of the observed data under the model gθ. The likelihood is
deﬁned only up to a positive multiplier, which we have taken to be one.
We think of L(θ; Z) as a function of θ, with our data Z ﬁxed.

Denote the logarithm of L(θ; Z) by

ℓ(θ; Z) =

=

N

i=1
X
N

i=1
X

ℓ(θ; zi)

log gθ(zi),

(8.12)

which we will sometimes abbreviate as ℓ(θ). This expression is called the
log-likelihood, and each value ℓ(θ; zi) = log gθ(zi) is called a log-likelihood
component. The method of maximum likelihood chooses the value θ = ˆθ
to maximize ℓ(θ; Z).

The likelihood function can be used to assess the precision of ˆθ. We need

a few more deﬁnitions. The score function is deﬁned by

N

˙ℓ(θ; Z) =

˙ℓ(θ; zi),

i=1
X

(8.13)

266

8. Model Inference and Averaging

where ˙ℓ(θ; zi) = ∂ℓ(θ; zi)/∂θ. Assuming that the likelihood takes its maxi-
mum in the interior of the parameter space, ˙ℓ(ˆθ; Z) = 0. The information
matrix is

I(θ) =

N

−

i=1
X

∂2ℓ(θ; zi)
∂θ∂θT .

(8.14)

When I(θ) is evaluated at θ = ˆθ, it is often called the observed information.
The Fisher information (or expected information) is

i(θ) = Eθ[I(θ)].

(8.15)

Finally, let θ0 denote the true value of θ.

A standard result says that the sampling distribution of the maximum

likelihood estimator has a limiting normal distribution

ˆθ

→

N (θ0, i(θ0)−1),

(8.16)

as N
that the sampling distribution of ˆθ may be approximated by

. Here we are independently sampling from gθ0(z). This suggests

→ ∞

N (ˆθ, i(ˆθ)−1) or N (ˆθ, I(ˆθ)−1),

(8.17)

where ˆθ represents the maximum likelihood estimate from the observed
data.

The corresponding estimates for the standard errors of ˆθj are obtained

from

i(ˆθ)−1
jj

and

I(ˆθ)−1
jj .

(8.18)

q

q

Conﬁdence points for θj can be constructed from either approximation

in (8.17). Such a conﬁdence point has the form

ˆθj −

z(1−α)

·

i(ˆθ)−1
jj

or

ˆθj −

z(1−α)

·

I(ˆθ)−1
jj ,

q

q
respectively, where z(1−α) is the 1
α percentile of the standard normal
−
distribution. More accurate conﬁdence intervals can be derived from the
likelihood function, by using the chi-squared approximation

2[ℓ(ˆθ)

ℓ(θ0)]

χ2
p,

(8.19)

−
where p is the number of components in θ. The resulting 1
dence interval is the set of all θ0 such that 2[ℓ(ˆθ)
ℓ(θ0)]
where χ2
p
p degrees of freedom.

2α conﬁ-
(1−2α),
χ2
p
2α percentile of the chi-squared distribution with

(1−2α) is the 1

−
≤

∼

−

−

8.3 Bayesian Methods

267

Let’s return to our smoothing example to see what maximum likelihood

yields. The parameters are θ = (β, σ2). The log-likelihood is

ℓ(θ) =

N
2

−

log σ22π

1
2σ2

−

N

i=1
X

h(xi)T β)2.

(yi −

(8.20)

The maximum likelihood estimate is obtained by setting ∂ℓ/∂β = 0 and
∂ℓ/∂σ2 = 0, giving

ˆβ = (HT H)−1HT y,

ˆσ2 =

1
N

ˆµ(xi))2,

(yi −

(8.21)

which are the same as the usual estimates given in (8.2) and below (8.3).
The information matrix for θ = (β, σ2) is block-diagonal, and the block

X

corresponding to β is

I(β) = (HT H)/σ2,

(8.22)

so that the estimated variance (HT H)−1 ˆσ2 agrees with the least squares
estimate (8.3).

8.2.3 Bootstrap versus Maximum Likelihood

In essence the bootstrap is a computer implementation of nonparametric or
parametric maximum likelihood. The advantage of the bootstrap over the
maximum likelihood formula is that it allows us to compute maximum like-
lihood estimates of standard errors and other quantities in settings where
no formulas are available.

In our example, suppose that we adaptively choose by cross-validation
the number and position of the knots that deﬁne the B-splines, rather
than ﬁx them in advance. Denote by λ the collection of knots and their
positions. Then the standard errors and conﬁdence bands should account
for the adaptive choice of λ, but there is no way to do this analytically.
With the bootstrap, we compute the B-spline smooth with an adaptive
choice of knots for each bootstrap sample. The percentiles of the resulting
curves capture the variability from both the noise in the targets as well as
that from ˆλ. In this particular example the conﬁdence bands (not shown)
don’t look much diﬀerent than the ﬁxed λ bands. But in other problems,
where more adaptation is used, this can be an important eﬀect to capture.

8.3 Bayesian Methods

In the Bayesian approach to inference, we specify a sampling model Pr(Z
θ)
(density or probability mass function) for our data given the parameters,

|

268

8. Model Inference and Averaging

and a prior distribution for the parameters Pr(θ) reﬂecting our knowledge
about θ before we see the data. We then compute the posterior distribution

Z) =

Pr(θ

|

Pr(Z
Pr(Z

θ)
|
θ)
|

·
·

Pr(θ)
Pr(θ)dθ

,

(8.23)

R

which represents our updated knowledge about θ after we see the data. To
understand this posterior distribution, one might draw samples from it or
summarize by computing its mean or mode. The Bayesian approach diﬀers
from the standard (“frequentist”) method for inference in its use of a prior
distribution to express the uncertainty present before seeing the data, and
to allow the uncertainty remaining after seeing the data to be expressed in
the form of a posterior distribution.

The posterior distribution also provides the basis for predicting the values

of a future observation znew, via the predictive distribution:

Pr(znew

Z) =

|

Z

Pr(znew

θ)

|

·

Pr(θ

|

Z)dθ.

(8.24)

ˆθ),
In contrast, the maximum likelihood approach would use Pr(znew
the data density evaluated at the maximum likelihood estimate, to predict
future data. Unlike the predictive distribution (8.24), this does not account
for the uncertainty in estimating θ.

|

Let’s walk through the Bayesian approach in our smoothing example.
We start with the parametric model given by equation (8.5), and assume
for the moment that σ2 is known. We assume that the observed feature
values x1, x2, . . . , xN are ﬁxed, so that the randomness in the data comes
solely from y varying around its mean µ(x).

The second ingredient we need is a prior distribution. Distributions on
functions are fairly complex entities: one approach is to use a Gaussian
process prior in which we specify the prior covariance between any two
function values µ(x) and µ(x′) (Wahba, 1990; Neal, 1996).

Here we take a simpler route: by considering a ﬁnite B-spline basis for
µ(x), we can instead provide a prior for the coeﬃcients β, and this implicitly
deﬁnes a prior for µ(x). We choose a Gaussian prior centered at zero

N (0, τ Σ)

β

∼

(8.25)

with the choices of the prior correlation matrix Σ and variance τ to be
discussed below. The implicit process prior for µ(x) is hence Gaussian,
with covariance kernel

K(x, x′) = cov[µ(x), µ(x′)]
h(x)T Σh(x′).

= τ

·

(8.26)

8.3 Bayesian Methods

269

)
x
(
µ

3

2

1

0

1
-

2
-

3
-

0.0

0.5

1.0

1.5
x

2.0

2.5

3.0

FIGURE 8.3. Smoothing example: Ten draws from the Gaussian prior distri-
bution for the function µ(x).

The posterior distribution for β is also Gaussian, with mean and covariance

E(β

|

Z) =

HT H +

(cid:18)

cov(β

Z) =

HT H +

|

−1

Σ−1

HT y,

(cid:19)

−1

Σ−1

σ2,

σ2
τ
σ2
τ

(cid:19)
with the corresponding posterior values for µ(x),

(cid:18)

E(µ(x)

|

Z) = h(x)T

HT H +

(cid:18)

cov[µ(x), µ(x′)

|

Z] = h(x)T

HT H +

(cid:18)

σ2
τ
σ2
τ

−1

Σ−1

HT y,

(cid:19)

−1

Σ−1

h(x′)σ2.

(cid:19)

(8.27)

(8.28)

How do we choose the prior correlation matrix Σ? In some settings the
prior can be chosen from subject matter knowledge about the parameters.
Here we are willing to say the function µ(x) should be smooth, and have
guaranteed this by expressing µ in a smooth low-dimensional basis of B-
splines. Hence we can take the prior correlation matrix to be the identity
Σ = I. When the number of basis functions is large, this might not be suf-
ﬁcient, and additional smoothness can be enforced by imposing restrictions
on Σ; this is exactly the case with smoothing splines (Section 5.8.1).

Figure 8.3 shows ten draws from the corresponding prior for µ(x). To
generate posterior values of the function µ(x), we generate values β′ from its
posterior (8.27), giving corresponding posterior value µ′(x) =
jhj(x).
Ten such posterior curves are shown in Figure 8.4. Two diﬀerent values
were used for the prior variance τ , 1 and 1000. Notice how similar the
right panel looks to the bootstrap distribution in the bottom left panel

7
1 β′

P

270

8. Model Inference and Averaging

τ = 1

τ = 1000

•

•
•

• ••
•
•
•
•

•
•

)
x
(
µ

5

4

3

2

1

0

1
-

•

•

•
••
••
•
•

)
x
(
µ

5

4

3

2

1

0

1
-

•

•

•

•
••••
•

• ••
•
•
••• •

•
•
••

0.0

0.5

1.0

•
••

•
• •

•

1.5
x

•

•

•

•
••••
•

• ••
•
•
••• •

•
•
••

•

•
•

• ••
•
•
•
•

•
•

•

•

•
••
••
•
•

2.0

2.5

3.0

•
••

•
• •

•

1.5
x

2.0

2.5

3.0

0.0

0.5

1.0

FIGURE 8.4. Smoothing example: Ten draws from the posterior distribution
for the function µ(x), for two diﬀerent values of the prior variance τ . The purple
curves are the posterior means.

of Figure 8.2 on page 263. This similarity is no accident. As τ
, the
posterior distribution (8.27) and the bootstrap distribution (8.7) coincide.
On the other hand, for τ = 1, the posterior curves µ(x) in the left panel
of Figure 8.4 are smoother than the bootstrap curves, because we have
imposed more prior weight on smoothness.

→ ∞

→ ∞

The distribution (8.25) with τ

is called a noninformative prior for
θ. In Gaussian models, maximum likelihood and parametric bootstrap anal-
yses tend to agree with Bayesian analyses that use a noninformative prior
for the free parameters. These tend to agree, because with a constant prior,
the posterior distribution is proportional to the likelihood. This correspon-
dence also extends to the nonparametric case, where the nonparametric
bootstrap approximates a noninformative Bayes analysis; Section 8.4 has
the details.

We have, however, done some things that are not proper from a Bayesian
point of view. We have used a noninformative (constant) prior for σ2 and
replaced it with the maximum likelihood estimate ˆσ2 in the posterior. A
more standard Bayesian analysis would also put a prior on σ (typically
g(σ)
1/σ), calculate a joint posterior for µ(x) and σ, and then integrate
out σ, rather than just extract the maximum of the posterior distribution
(“MAP” estimate).

∝

8.4 Relationship Between the Bootstrap and Bayesian Inference

271

8.4 Relationship Between the Bootstrap and

Bayesian Inference

Consider ﬁrst a very simple example, in which we observe a single obser-
vation z from a normal distribution

N (θ, 1).

z

∼

(8.29)

To carry out a Bayesian analysis for θ, we need to specify a prior. The
N (0, τ ) giving posterior
most convenient and common choice would be θ
distribution

∼

θ

z

|

∼

N

(cid:18)

z
1 + 1/τ

,

1
1 + 1/τ

.

(cid:19)

(8.30)

Now the larger we take τ , the more concentrated the posterior becomes
around the maximum likelihood estimate ˆθ = z. In the limit as τ
we
obtain a noninformative (constant) prior, and the posterior distribution is

→ ∞

θ

z

|

∼

N (z, 1).

(8.31)

This is the same as a parametric bootstrap distribution in which we gen-
erate bootstrap values z∗ from the maximum likelihood estimate of the
sampling density N (z, 1).

There are three ingredients that make this correspondence work:

1. The choice of noninformative prior for θ.

2. The dependence of the log-likelihood ℓ(θ; Z) on the data Z only
through the maximum likelihood estimate ˆθ. Hence we can write the
log-likelihood as ℓ(θ; ˆθ).

3. The symmetry of the log-likelihood in θ and ˆθ, that is, ℓ(θ; ˆθ) =

ℓ(ˆθ; θ) + constant.

Properties (2) and (3) essentially only hold for the Gaussian distribu-
tion. However, they also hold approximately for the multinomial distribu-
tion, leading to a correspondence between the nonparametric bootstrap
and Bayes inference, which we outline next.

Assume that we have a discrete sample space with L categories. Let wj be
the probability that a sample point falls in category j, and ˆwj the observed
proportion in category j. Let w = (w1, w2, . . . , wL), ˆw = ( ˆw1, ˆw2, . . . , ˆwL).
Denote our estimator by S( ˆw); take as a prior distribution for w a sym-
metric Dirichlet distribution with parameter a:

w

∼

DiL(a1),

(8.32)

272

8. Model Inference and Averaging

that is, the prior probability mass function is proportional to
Then the posterior density of w is

w

∼

DiL(a1 + N ˆw),

L

ℓ=1 wa−1

ℓ

.

Q

(8.33)

where N is the sample size. Letting a
gives

→

0 to obtain a noninformative prior

w

∼

DiL(N ˆw).

(8.34)

Now the bootstrap distribution, obtained by sampling with replacement
from the data, can be expressed as sampling the category proportions from
a multinomial distribution. Speciﬁcally,

N ˆw∗

∼

Mult(N, ˆw),

(8.35)

N

where Mult(N, ˆw) denotes a multinomial distribution, having probability
. This distribution is similar to the pos-
mass function
terior distribution above, having the same support, same mean, and nearly
the same covariance matrix. Hence the bootstrap distribution of S( ˆw∗) will
closely approximate the posterior distribution of S(w).

ˆwN ˆw∗

1 ,...,N ˆw∗

(cid:1) Q

N ˆw∗

(cid:0)

L

ℓ

ℓ

In this sense, the bootstrap distribution represents an (approximate)
nonparametric, noninformative posterior distribution for our parameter.
But this bootstrap distribution is obtained painlessly—without having to
formally specify a prior and without having to sample from the posterior
distribution. Hence we might think of the bootstrap distribution as a “poor
man’s” Bayes posterior. By perturbing the data, the bootstrap approxi-
mates the Bayesian eﬀect of perturbing the parameters, and is typically
much simpler to carry out.

8.5 The EM Algorithm

The EM algorithm is a popular tool for simplifying diﬃcult maximum
likelihood problems. We ﬁrst describe it in the context of a simple mixture
model.

8.5.1 Two-Component Mixture Model

In this section we describe a simple mixture model for density estimation,
and the associated EM algorithm for carrying out maximum likelihood
estimation. This has a natural connection to Gibbs sampling methods for
Bayesian inference. Mixture models are discussed and demonstrated in sev-
eral other parts of the book, in particular Sections 6.8, 12.7 and 13.2.3.

The left panel of Figure 8.5 shows a histogram of the 20 ﬁctitious data

points in Table 8.1.

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

8.5 The EM Algorithm

273

• •• • ••

••••

•

•

• •• • • ••

•

y
t
i
s
n
e
d

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

0

2

4

6

0

2

4

6

y

y

FIGURE 8.5. Mixture example. (Left panel:) Histogram of data. (Right panel:)
Maximum likelihood ﬁt of Gaussian densities (solid red) and responsibility (dotted
green) of the left component density for observation y, as a function of y.

TABLE 8.1. Twenty ﬁctitious data points used in the two-component mixture
example in Figure 8.5.

-0.39
0.06

0.12
0.48

0.94
1.01

1.67
1.68

1.76
1.80

2.44
3.25

3.72
4.12

4.28
4.60

4.92
5.28

5.53
6.22

We would like to model the density of the data points, and due to the
apparent bi-modality, a Gaussian distribution would not be appropriate.
There seems to be two separate underlying regimes, so instead we model
Y as a mixture of two normal distributions:

Y1 ∼
Y2 ∼
Y = (1

N (µ1, σ2
N (µ2, σ2
∆)

1),
2),

−

Y1 + ∆

Y2,

·

·

(8.36)

0, 1
}

with Pr(∆ = 1) = π. This generative representation is
where ∆
∈ {
explicit: generate a ∆
with probability π, and then depending on
the outcome, deliver either Y1 or Y2. Let φθ(x) denote the normal density
with parameters θ = (µ, σ2). Then the density of Y is

0, 1
}

∈ {

gY (y) = (1

−

π)φθ1(y) + πφθ2(y).

(8.37)

Now suppose we wish to ﬁt this model to the data in Figure 8.5 by maxi-
mum likelihood. The parameters are

θ = (π, θ1, θ2) = (π, µ1, σ2

1, µ2, σ2

2).

(8.38)

The log-likelihood based on the N training cases is

N

ℓ(θ; Z) =

log[(1

i=1
X

π)φθ1(yi) + πφθ2(yi)].

(8.39)

−

274

8. Model Inference and Averaging

Direct maximization of ℓ(θ; Z) is quite diﬃcult numerically, because of
the sum of terms inside the logarithm. There is, however, a simpler ap-
proach. We consider unobserved latent variables ∆i taking values 0 or 1 as
in (8.36): if ∆i = 1 then Yi comes from model 2, otherwise it comes from
model 1. Suppose we knew the values of the ∆i’s. Then the log-likelihood
would be

ℓ0(θ; Z, ∆) =

N

i=1
X

[(1

−

N

∆i) log φθ1(yi) + ∆i log φθ2(yi)]

[(1

−

∆i) log(1

−

π) + ∆i log π] ,

(8.40)

+

i=1
X

and the maximum likelihood estimates of µ1 and σ2
1 would be the sample
mean and variance for those data with ∆i = 0, and similarly those for µ2
and σ2
2 would be the sample mean and variance of the data with ∆i = 1.
The estimate of π would be the proportion of ∆i = 1.

Since the values of the ∆i’s are actually unknown, we proceed in an

iterative fashion, substituting for each ∆i in (8.40) its expected value

γi(θ) = E(∆i|

θ, Z) = Pr(∆i = 1
|

θ, Z),

(8.41)

also called the responsibility of model 2 for observation i. We use a proce-
dure called the EM algorithm, given in Algorithm 8.1 for the special case of
Gaussian mixtures. In the expectation step, we do a soft assignment of each
observation to each model: the current estimates of the parameters are used
to assign responsibilities according to the relative density of the training
points under each model. In the maximization step, these responsibilities
are used in weighted maximum-likelihood ﬁts to update the estimates of
the parameters.

P

A good way to construct initial guesses for ˆµ1 and ˆµ2 is simply to choose
1 and ˆσ2
2 can be set equal to the overall
¯y)2/N . The mixing proportion ˆπ can be started

two of the yi at random. Both ˆσ2
sample variance
at the value 0.5.

i=1(yi −

N

1, ˆσ2

Note that the actual maximizer of the likelihood occurs when we put a
spike of inﬁnite height at any one data point, that is, ˆµ1 = yi for some
i and ˆσ2
1 = 0. This gives inﬁnite likelihood, but is not a useful solution.
Hence we are actually looking for a good local maximum of the likelihood,
one for which ˆσ2
2 > 0. To further complicate matters, there can be
more than one local maximum having ˆσ2
2 > 0. In our example, we
ran the EM algorithm with a number of diﬀerent initial guesses for the
parameters, all having ˆσ2
k > 0.5, and chose the run that gave us the highest
maximized likelihood. Figure 8.6 shows the progress of the EM algorithm in
maximizing the log-likelihood. Table 8.2 shows ˆπ =
i ˆγi/N , the maximum
likelihood estimate of the proportion of observations in class 2, at selected
iterations of the EM procedure.

1, ˆσ2

P

Algorithm 8.1 EM Algorithm for Two-component Gaussian Mixture.

8.5 The EM Algorithm

275

1. Take initial guesses for the parameters ˆµ1, ˆσ2

1, ˆµ2, ˆσ2

2, ˆπ (see text).

2. Expectation Step: compute the responsibilities

ˆγi =

ˆπφˆθ2

(yi)
(yi) + ˆπφˆθ2

(1

−

ˆπ)φˆθ1

, i = 1, 2, . . . , N.

(8.42)

(yi)

3. Maximization Step: compute the weighted means and variances:

ˆµ1 =

P

N
i=1(1
ˆγi)yi
−
N
i=1(1
ˆγi)
−
N
i=1 ˆγiyi
N
i=1 ˆγi

P

,

,

ˆσ2
1 =

ˆσ2
2 =

P

P

ˆγi)(yi −
ˆγi)
−
ˆµ2)2

N
i=1(1
−
N
i=1(1
i=1 ˆγi(yi −
P
N
i=1 ˆγi

N

,

ˆµ1)2

,

P
ˆµ2 =

and the mixing probability ˆπ =

P

N
i=1 ˆγi/N .

P

4. Iterate steps 2 and 3 until convergence.

P

TABLE 8.2. Selected iterations of the EM algorithm for mixture example.

Iteration
1
5
10
15
20

ˆπ
0.485
0.493
0.523
0.544
0.546

The ﬁnal maximum likelihood estimates are

ˆµ1 = 4.62,
ˆµ2 = 1.06,

ˆσ2
1 = 0.87,
ˆσ2
2 = 0.77,

ˆπ = 0.546.

The right panel of Figure 8.5 shows the estimated Gaussian mixture density
from this procedure (solid red curve), along with the responsibilities (dotted
green curve). Note that mixtures are also useful for supervised learning; in
Section 6.7 we show how the Gaussian mixture model leads to a version of
radial basis functions.

276

8. Model Inference and Averaging

o o o o o o o o o o o o

o

o

o

o

o o o

9
3
-

0
4
-

1
4
-

2
4
-

3
4
-

4
4
-

d
o
o
h

i
l

e
k

i
l
-
g
o
L
a
t
a
D
d
e
v
r
e
s
b
O

o

5

10

Iteration

15

20

FIGURE 8.6. EM algorithm: observed data log-likelihood as a function of the
iteration number.

8.5.2 The EM Algorithm in General

The above procedure is an example of the EM (or Baum–Welch) algorithm
for maximizing likelihoods in certain classes of problems. These problems
are ones for which maximization of the likelihood is diﬃcult, but made
easier by enlarging the sample with latent (unobserved) data. This is called
data augmentation. Here the latent data are the model memberships ∆i.
In other problems, the latent data are actual data that should have been
observed but are missing.

Algorithm 8.2 gives the general formulation of the EM algorithm. Our
observed data is Z, having log-likelihood ℓ(θ; Z) depending on parameters
θ. The latent or missing data is Zm, so that the complete data is T =
(Z, Zm) with log-likelihood ℓ0(θ; T), ℓ0 based on the complete density. In
the mixture problem (Z, Zm) = (y, ∆), and ℓ0(θ; T) is given in (8.40).

In our mixture example, E(ℓ0(θ′; T)

Z, ˆθ(j)) is simply (8.40) with the ∆i
|
replaced by the responsibilities ˆγi(ˆθ), and the maximizers in step 3 are just
weighted means and variances.

We now give an explanation of why the EM algorithm works in general.
Since

Pr(Zm

|

Z, θ′) =

we can write

Pr(Zm, Z
|
θ′)
Pr(Z

θ′)

|

Pr(Z

θ′) =

Pr(T
Pr(Zm

θ′)
|
Z, θ′)
|

.

|
In terms of log-likelihoods, we have ℓ(θ′; Z) = ℓ0(θ′; T)
ℓ1 is based on the conditional density Pr(Zm
|
expectations with respect to the distribution of T
θ gives

|

,

(8.44)

(8.45)

−

ℓ1(θ′; Zm

Z), where
Z, θ′). Taking conditional
Z governed by parameter

|

ℓ(θ′; Z) = E[ℓ0(θ′; T)

Z, θ]

|

−

E[ℓ1(θ′; Zm

Z, θ]

Z)

|

|

 
 
8.5 The EM Algorithm

277

Algorithm 8.2 The EM Algorithm.

1. Start with initial guesses for the parameters ˆθ(0).

2. Expectation Step: at the jth step, compute

Q(θ′, ˆθ(j)) = E(ℓ0(θ′; T)

Z, ˆθ(j))

|
as a function of the dummy argument θ′.

(8.43)

3. Maximization Step: determine the new estimate ˆθ(j+1) as the maxi-

mizer of Q(θ′, ˆθ(j)) over θ′.

4. Iterate steps 2 and 3 until convergence.

Q(θ′, θ)

−

≡

R(θ′, θ).

(8.46)

In the M step, the EM algorithm maximizes Q(θ′, θ) over θ′, rather than
the actual objective function ℓ(θ′; Z). Why does it succeed in maximizing
ℓ(θ′; Z)? Note that R(θ∗, θ) is the expectation of a log-likelihood of a density
(indexed by θ∗), with respect to the same density indexed by θ, and hence
(by Jensen’s inequality) is maximized as a function of θ∗, when θ∗ = θ (see
Exercise 8.1). So if θ′ maximizes Q(θ′, θ), we see that

ℓ(θ′; Z)

−

ℓ(θ; Z) = [Q(θ′, θ)

0.

≥

Q(θ, θ)]

−

−

[R(θ′, θ)

R(θ, θ)]

−

(8.47)

Hence the EM iteration never decreases the log-likelihood.

This argument also makes it clear that a full maximization in the M
step is not necessary: we need only to ﬁnd a value ˆθ(j+1) so that Q(θ′, ˆθ(j))
increases as a function of the ﬁrst argument, that is, Q(ˆθ(j+1), ˆθ(j)) >
Q(ˆθ(j), ˆθ(j)). Such procedures are called GEM (generalized EM) algorithms.
The EM algorithm can also be viewed as a minorization procedure: see
Exercise 8.7.

8.5.3 EM as a Maximization–Maximization Procedure

Here is a diﬀerent view of the EM procedure, as a joint maximization
algorithm. Consider the function

F (θ′, ˜P ) = E ˜P [ℓ0(θ′; T)]

E ˜P [log ˜P (Zm)].

−

(8.48)

Here ˜P (Zm) is any distribution over the latent data Zm. In the mixture
example, ˜P (Zm) comprises the set of probabilities γi = Pr(∆i = 1
θ, Z).
|
Note that F evaluated at ˜P (Zm) = Pr(Zm
Z, θ′), is the log-likelihood of

|

278

8. Model Inference and Averaging

t

s
r
e
e
m
a
r
a
P

l

e
d
o
M

4

3

2

1

0

0.3

0.1

0.7

0.5

0.9

E

M

M

E

1

2

3

4

5

Latent Data Parameters

FIGURE 8.7. Maximization–maximization view of the EM algorithm. Shown
are the contours of the (augmented) observed data log-likelihood F (θ′, ˜P ). The
E step is equivalent to maximizing the log-likelihood over the parameters of the
latent data distribution. The M step maximizes it over the parameters of the
log-likelihood. The red curve corresponds to the observed data log-likelihood, a
proﬁle obtained by maximizing F (θ′, ˜P ) for each value of θ′.

the observed data, from (8.46)1. The function F expands the domain of
the log-likelihood, to facilitate its maximization.

The EM algorithm can be viewed as a joint maximization method for F
over θ′ and ˜P (Zm), by ﬁxing one argument and maximizing over the other.
The maximizer over ˜P (Zm) for ﬁxed θ′ can be shown to be

˜P (Zm) = Pr(Zm

Z, θ′)

|

(8.49)

(Exercise 8.2). This is the distribution computed by the E step, for example,
(8.42) in the mixture example. In the M step, we maximize F (θ′, ˜P ) over θ′
with ˜P ﬁxed: this is the same as maximizing the ﬁrst term E ˜P [ℓ0(θ′; T)
Z, θ]
since the second term does not involve θ′.

Finally, since F (θ′, ˜P ) and the observed data log-likelihood agree when
˜P (Zm) = Pr(Zm
Z, θ′), maximization of the former accomplishes maxi-
mization of the latter. Figure 8.7 shows a schematic view of this process.
This view of the EM algorithm leads to alternative maximization proce-

|

|

1 (8.46) holds for all θ, including θ = θ′.

 
8.6 MCMC for Sampling from the Posterior

279

Algorithm 8.3 Gibbs Sampler.

1. Take some initial values U (0)

k , k = 1, 2, . . . , K.

2. Repeat for t = 1, 2, . . . , . :

For k = 1, 2, . . . , K generate U (t)
k
k−1, U (t−1)

U (t)
1 , . . . , U (t)

from
k+1 , . . . , U (t−1)

K

Pr(U (t)
k |

).

3. Continue step 2 until the joint distribution of (U (t)

1 , U (t)

2 , . . . , U (t)
K )

does not change.

dures. For example, one does not need to maximize with respect to all of
the latent data parameters at once, but could instead maximize over one
of them at a time, alternating with the M step.

8.6 MCMC for Sampling from the Posterior

Having deﬁned a Bayesian model, one would like to draw samples from
the resulting posterior distribution, in order to make inferences about the
parameters. Except for simple models, this is often a diﬃcult computa-
tional problem. In this section we discuss the Markov chain Monte Carlo
(MCMC) approach to posterior sampling. We will see that Gibbs sampling,
an MCMC procedure, is closely related to the EM algorithm: the main dif-
ference is that it samples from the conditional distributions rather than
maximizing over them.

Consider ﬁrst the following abstract problem. We have random variables
U1, U2, . . . , UK and we wish to draw a sample from their joint distribution.
Suppose this is diﬃcult to do, but it is easy to simulate from the conditional
U1, U2, . . . , Uj−1, Uj+1, . . . , UK ), j = 1, 2, . . . , K. The
distributions Pr(Uj|
Gibbs sampling procedure alternatively simulates from each of these distri-
butions and when the process stabilizes, provides a sample from the desired
joint distribution. The procedure is deﬁned in Algorithm 8.3.

Under regularity conditions it can be shown that this procedure even-
tually stabilizes, and the resulting random variables are indeed a sample
from the joint distribution of U1, U2, . . . , UK . This occurs despite the fact
that the samples (U (t)
K ) are clearly not independent for dif-
ferent t. More formally, Gibbs sampling produces a Markov chain whose
stationary distribution is the true joint distribution, and hence the term
“Markov chain Monte Carlo.” It is not surprising that the true joint dis-
tribution is stationary under this process, as the successive steps leave the
marginal distributions of the Uk’s unchanged.

2 , . . . , U (t)

1 , U (t)

280

8. Model Inference and Averaging

Note that we don’t need to know the explicit form of the conditional
densities, but just need to be able to sample from them. After the procedure
reaches stationarity, the marginal density of any subset of the variables
can be approximated by a density estimate applied to the sample values.
However if the explicit form of the conditional density Pr(Uk,
= k)
is available, a better estimate of say the marginal density of Uk can be
obtained from (Exercise 8.3):

Uℓ, ℓ

|

1
m + 1)

M

t=m
X

(M

−

Pr(u

U (t)
ℓ

|

, ℓ

= k).

(8.50)

PrUk (u) =

c

Here we have averaged over the last M
to allow for an initial “burn-in” period before stationarity is reached.

m + 1 members of the sequence,

−

Now getting back to Bayesian inference, our goal is to draw a sample from
the joint posterior of the parameters given the data Z. Gibbs sampling will
be helpful if it is easy to sample from the conditional distribution of each
parameter given the other parameters and Z. An example—the Gaussian
mixture problem—is detailed next.

There is a close connection between Gibbs sampling from a posterior and
the EM algorithm in exponential family models. The key is to consider the
latent data Zm from the EM procedure to be another parameter for the
Gibbs sampler. To make this explicit for the Gaussian mixture problem,
we take our parameters to be (θ, Zm). For simplicity we ﬁx the variances
1, σ2
σ2
2 and mixing proportion π at their maximum likelihood values so that
the only unknown parameters in θ are the means µ1 and µ2. The Gibbs
sampler for the mixture problem is given in Algorithm 8.4. We see that
steps 2(a) and 2(b) are the same as the E and M steps of the EM pro-
cedure, except that we sample rather than maximize. In step 2(a), rather
θ, Z),
than compute the maximum likelihood responsibilities γi = E(∆i|
the Gibbs sampling procedure simulates the latent data ∆i from the distri-
θ, Z). In step 2(b), rather than compute the maximizers of
butions Pr(∆i|
the posterior Pr(µ1, µ2, ∆
Z) we simulate from the conditional distribution
∆, Z).
Pr(µ1, µ2|
Figure 8.8 shows 200 iterations of Gibbs sampling, with the mean param-
eters µ1 (lower) and µ2 (upper) shown in the left panel, and the proportion
i ∆i/N on the right. Horizontal broken lines have
of class 2 observations
been drawn at the maximum likelihood estimate values ˆµ1, ˆµ2 and
i ˆγi/N
in each case. The values seem to stabilize quite quickly, and are distributed
evenly around the maximum likelihood values.

P

P

|

The above mixture model was simpliﬁed, in order to make the clear
connection between Gibbs sampling and the EM algorithm. More realisti-
cally, one would put a prior distribution on the variances σ2
2 and mixing
proportion π, and include separate Gibbs sampling steps in which we sam-
ple from their posterior distributions, conditional on the other parameters.
One can also incorporate proper (informative) priors for the mean param-

1, σ2

6
6
8.6 MCMC for Sampling from the Posterior

281

Algorithm 8.4 Gibbs sampling for mixtures.

1. Take some initial values θ(0) = (µ(0)

1 , µ(0)
2 ).

2. Repeat for t = 1, 2, . . . , .

(a) For i = 1, 2, . . . , N generate ∆(t)
ˆγi(θ(t)), from equation (8.42).

i ∈ {

0, 1
}

with Pr(∆(t)

i = 1) =

(b) Set

ˆµ1 =

ˆµ2 =

∆(t)
i )
·
∆(t)
i )

yi

,

N
i=1(1
−
N
i=1(1
−
i=1 ∆(t)
N
P

i

N

·
i=1 ∆(t)

i

P

P

yi

,

and generate µ(t)

1 ∼

P
1) and µ(t)
N (ˆµ1, ˆσ2

2 ∼

N (ˆµ2, ˆσ2

2).

3. Continue step 2 until the joint distribution of (∆(t), µ(t)

1 , µ(t)

2 ) doesn’t

change

8

6

4

2

0

t

s
r
e
e
m
a
r
a
P
n
a
e
M

n
o

i
t
r
o
p
o
r
P
g
n
x
M

i

i

7

.

0

6

.

0

5
0

.

4
0

.

3

.

0

0

50

100

150

200

0

50

100

150

200

Gibbs Iteration

Gibbs Iteration

FIGURE 8.8. Mixture example. (Left panel:) 200 values of the two mean param-
eters from Gibbs sampling; horizontal lines are drawn at the maximum likelihood
estimates ˆµ1, ˆµ2. (Right panel:) Proportion of values with ∆i = 1, for each of the
200 Gibbs sampling iterations; a horizontal line is drawn at

Pi ˆγi/N .

 
 
282

8. Model Inference and Averaging

eters. These priors must not be improper as this will lead to a degenerate
posterior, with all the mixing weight on one component.

Gibbs sampling is just one of a number of recently developed procedures
for sampling from posterior distributions. It uses conditional sampling of
each parameter given the rest, and is useful when the structure of the prob-
lem makes this sampling easy to carry out. Other methods do not require
such structure, for example the Metropolis–Hastings algorithm. These and
other computational Bayesian methods have been applied to sophisticated
learning algorithms such as Gaussian process models and neural networks.
Details may be found in the references given in the Bibliographic Notes at
the end of this chapter.

8.7 Bagging

Earlier we introduced the bootstrap as a way of assessing the accuracy of a
parameter estimate or a prediction. Here we show how to use the bootstrap
to improve the estimate or prediction itself. In Section 8.4 we investigated
the relationship between the bootstrap and Bayes approaches, and found
that the bootstrap mean is approximately a posterior average. Bagging
further exploits this connection.

(x1, y1), (x2, y2), . . . , (xN , yN )
{

Consider ﬁrst the regression problem. Suppose we ﬁt a model to our
training data Z =
, obtaining the predic-
}
tion ˆf (x) at input x. Bootstrap aggregation or bagging averages this predic-
tion over a collection of bootstrap samples, thereby reducing its variance.
For each bootstrap sample Z∗b, b = 1, 2, . . . , B, we ﬁt our model, giving
prediction ˆf ∗b(x). The bagging estimate is deﬁned by

ˆfbag(x) =

ˆf ∗b(x).

1
B

B

Xb=1

(8.51)

∼

Denote by ˆ
the empirical distribution putting equal probability 1/N on
P
each of the data points (xi, yi). In fact the “true” bagging estimate is
ˆf ∗(x), where Z∗ =
1), (x∗
1, y∗
and each
deﬁned by E ˆP
ˆ
(x∗
i , y∗
. Expression (8.51) is a Monte Carlo estimate of the true
i )
P
.
bagging estimate, approaching it as B

2), . . . , (x∗

(x∗
{

N , y∗

2, y∗

The bagged estimate (8.51) will diﬀer from the original estimate ˆf (x)
only when the latter is a nonlinear or adaptive function of the data. For
example, to bag the B-spline smooth of Section 8.2.1, we average the curves
in the bottom left panel of Figure 8.2 at each value of x. The B-spline
smoother is linear in the data if we ﬁx the inputs; hence if we sample using
the parametric bootstrap in equation (8.6), then ˆfbag(x)
→ ∞
(Exercise 8.4). Hence bagging just reproduces the original smooth in the

ˆf (x) as B

→ ∞

N )

→

}

8.7 Bagging

283

top left panel of Figure 8.2. The same is approximately true if we were to
bag using the nonparametric bootstrap.

A more interesting example is a regression tree, where ˆf (x) denotes the
tree’s prediction at input vector x (regression trees are described in Chap-
ter 9). Each bootstrap tree will typically involve diﬀerent features than the
original, and might have a diﬀerent number of terminal nodes. The bagged
estimate is the average prediction at x from these B trees.

Now suppose our tree produces a classiﬁer ˆG(x) for a K-class response.
Here it is useful to consider an underlying indicator-vector function ˆf (x),
1 zeroes, such that ˆG(x) = arg maxk ˆf (x).
with value a single one and K
Then the bagged estimate ˆfbag(x) (8.51) is a K-vector [p1(x), p2(x), . . . ,
pK (x)], with pk(x) equal to the proportion of trees predicting class k at x.
The bagged classiﬁer selects the class with the most “votes” from the B
trees, ˆGbag(x) = arg maxk ˆfbag(x).

−

Often we require the class-probability estimates at x, rather than the
classiﬁcations themselves. It is tempting to treat the voting proportions
pk(x) as estimates of these probabilities. A simple two-class example shows
that they fail in this regard. Suppose the true probability of class 1 at x is
0.75, and each of the bagged classiﬁers accurately predict a 1. Then p1(x) =
1, which is incorrect. For many classiﬁers ˆG(x), however, there is already
an underlying function ˆf (x) that estimates the class probabilities at x (for
trees, the class proportions in the terminal node). An alternative bagging
strategy is to average these instead, rather than the vote indicator vectors.
Not only does this produce improved estimates of the class probabilities,
but it also tends to produce bagged classiﬁers with lower variance, especially
for small B (see Figure 8.10 in the next example).

8.7.1 Example: Trees with Simulated Data

x1 ≤

We generated a sample of size N = 30, with two classes and p = 5 features,
each having a standard Gaussian distribution with pairwise correlation
0.95. The response Y was generated according to Pr(Y = 1
0.5) = 0.2,
|
Pr(Y = 1
x1 > 0.5) = 0.8. The Bayes error is 0.2. A test sample of size 2000
|
was also generated from the same population. We ﬁt classiﬁcation trees to
the training sample and to each of 200 bootstrap samples (classiﬁcation
trees are described in Chapter 9). No pruning was used. Figure 8.9 shows
the original tree and eleven bootstrap trees. Notice how the trees are all
diﬀerent, with diﬀerent splitting features and cutpoints. The test error for
the original tree and the bagged tree is shown in Figure 8.10. In this ex-
ample the trees have high variance due to the correlation in the predictors.
Bagging succeeds in smoothing out this variance and hence reducing the
test error.

Bagging can dramatically reduce the variance of unstable procedures
like trees, leading to improved prediction. A simple argument shows why

284

8. Model Inference and Averaging

Original Tree

x.1 < 0.395

|

1

1

0

0

1

0

0

1

b = 3

x.2 < 0.285

|

0

0

1

0

0

1

1

1

b = 6

x.1 < 0.395

|

1

b = 1

x.1 < 0.555

|

0

1

b = 2

x.2 < 0.205

|

0

1

1

0

0

1

0

1

b = 4

x.3 < 0.985

|

b = 5

x.4 < −1.36

|

0

1

1

0

1

b = 7

x.1 < 0.395

|

0

1

1

0

1

1

0

b = 8

x.3 < 0.985

|

1

1

0

0

0

1

0

1

1

1

0

0

1

0

0

b = 9

x.1 < 0.395

|

b = 10

x.1 < 0.555

|

1

b = 11

x.1 < 0.555

|

1

0

1

0

0

1

0

1

1

0

0

1

0

1

FIGURE 8.9. Bagging trees on simulated dataset. The top left panel shows the
original tree. Eleven trees grown on bootstrap samples are shown. For each tree,
the top split is annotated.

r
o
r
r

E

t
s
e
T

0
5
.
0

5
4
.
0

0
4
.
0

5
3
.
0

0
3
.
0

5
2
.
0

0
2
.
0

8.7 Bagging

285

Consensus
Probability

Original Tree

Bagged Trees

Bayes

0

50

100

150

200

Number of Bootstrap Samples

FIGURE 8.10. Error curves for the bagging example of Figure 8.9. Shown is
the test error of the original tree and bagged trees as a function of the number of
bootstrap samples. The orange points correspond to the consensus vote, while the
green points average the probabilities.

bagging helps under squared-error loss, in short because averaging reduces
variance and leaves bias unchanged.

Assume our training observations (xi, yi),

i = 1, . . . , N are indepen-
dently drawn from a distribution
, and consider the ideal aggregate es-
timator fag(x) = EP ˆf ∗(x). Here x is ﬁxed and the bootstrap dataset Z∗
consists of observations x∗
. Note that
fag(x) is a bagging estimate, drawing bootstrap samples from the actual
population
rather than the data. It is not an estimate that we can use
in practice, but is convenient for analysis. We can write

i , i = 1, 2, . . . , N sampled from

i , y∗

P

P

P

EP [Y

−

ˆf ∗(x)]2 = EP [Y
= EP [Y
EP [Y

≥

−

−
−

ˆf ∗(x)]2

fag(x) + fag(x)
fag(x)]2 + EP [ ˆf ∗(x)
fag(x)]2.

−

fag(x)]2

−

(8.52)

The extra error on the right-hand side comes from the variance of ˆf ∗(x)
around its mean fag(x). Therefore true population aggregation never in-
creases mean squared error. This suggests that bagging—drawing samples
from the training data— will often decrease mean-squared error.

The above argument does not hold for classiﬁcation under 0-1 loss, be-
cause of the nonadditivity of bias and variance. In that setting, bagging a

 
286

8. Model Inference and Averaging

good classiﬁer can make it better, but bagging a bad classiﬁer can make it
worse. Here is a simple example, using a randomized rule. Suppose Y = 1
for all x, and the classiﬁer ˆG(x) predicts Y = 1 (for all x) with proba-
bility 0.4 and predicts Y = 0 (for all x) with probability 0.6. Then the
misclassiﬁcation error of ˆG(x) is 0.6 but that of the bagged classiﬁer is 1.0.
For classiﬁcation we can understand the bagging eﬀect in terms of a
consensus of independent weak learners (Dietterich, 2000a). Let the Bayes
optimal decision at x be G(x) = 1 in a two-class example. Suppose each
of the weak learners G∗
b have an error-rate eb = e < 0.5, and let S1(x) =
b (x) = 1) be the consensus vote for class 1. Since the weak learn-
e), and Pr(S1 >
ers are assumed to be independent, S1(x)
P
B/2)
1 as B gets large. This concept has been popularized outside of
statistics as the “Wisdom of Crowds” (Surowiecki, 2004) — the collective
knowledge of a diverse and independent body of people typically exceeds
the knowledge of any single individual, and can be harnessed by voting.
Of course, the main caveat here is “independent,” and bagged trees are
not. Figure 8.11 illustrates the power of a consensus vote in a simulated
example, where only 30% of the voters have some knowledge.

B
b=1 I(G∗

Bin(B, 1

→

∼

−

In Chapter 15 we see how random forests improve on bagging by reducing

the correlation between the sampled trees.

Note that when we bag a model, any simple structure in the model is
lost. As an example, a bagged tree is no longer a tree. For interpretation
of the model this is clearly a drawback. More stable procedures like near-
est neighbors are typically not aﬀected much by bagging. Unfortunately,
the unstable models most helped by bagging are unstable because of the
emphasis on interpretability, and this is lost in the bagging process.

Figure 8.12 shows an example where bagging doesn’t help. The 100 data
points shown have two features and two classes, separated by the gray
linear boundary x1 + x2 = 1. We choose as our classiﬁer ˆG(x) a single
axis-oriented split, choosing the split along either x1 or x2 that produces
the largest decrease in training misclassiﬁcation error.

The decision boundary obtained from bagging the 0-1 decision rule over
B = 50 bootstrap samples is shown by the blue curve in the left panel.
It does a poor job of capturing the true boundary. The single split rule,
derived from the training data, splits near 0 (the middle of the range of x1
or x2), and hence has little contribution away from the center. Averaging
the probabilities rather than the classiﬁcations does not help here. Bagging
estimates the expected class probabilities from the single split rule, that is,
averaged over many replications. Note that the expected class probabilities
computed by bagging cannot be realized on any single replication, in the
same way that a woman cannot have 2.4 children. In this sense, bagging
increases somewhat the space of models of the individual base classiﬁer.
However, it doesn’t help in this and many other examples where a greater
enlargement of the model class is needed. “Boosting” is a way of doing this

8.7 Bagging

287

Wisdom of Crowds

Consensus
Individual

0
1
f
o

t
u
o
t
c
e
r
r
o
C
d
e
t
c
e
p
x
E

0
1

8

6

4

2

0

0.25

0.50

0.75

1.00

P −  Probability of Informed Person Being Correct

FIGURE 8.11. Simulated academy awards voting. 50 members vote in 10 cat-
egories, each with 4 nominations. For any category, only 15 voters have some
knowledge, represented by their probability of selecting the “correct” candidate in
that category (so P = 0.25 means they have no knowledge). For each category, the
15 experts are chosen at random from the 50. Results show the expected correct
(based on 50 simulations) for the consensus, as well as for the individuals. The
error bars indicate one standard deviation. We see, for example, that if the 15
informed for a category have a 50% chance of selecting the correct candidate, the
consensus doubles the expected performance of an individual.

 
 
 
 
288

8. Model Inference and Averaging

Bagged Decision Rule

Boosted Decision Rule

•
•

•
•
•

•
•

•

•

•

•
•
•
•
•
•
•
•
•
•
•

•
•

•

•

•

•

•
•

•

•

•

•

•

•
•
•
•
•

•

•

•

•

•
•

•
•

••

•
•

•

•

•
•

•

•

•

•
•

•
•

•

•

•

•

•
•

•
•

•

•

•
••

•

•
•

•

•
•
•
•

•

•

•

•
•
•
•

•

•

•
•
•

•

•

•

•

•
•

•

•

•
•
•

•

•

•

•

•

•

•

•

•
•

•
•
•

•

•

•

•
•
•

•
•
•
•

•

•
•
•

•

•

•
•
•
•

•
•
•

••

•

•
•
•
•

•

•
•

•

•
•

•

•
•
•
•
•

•

•
•

•

•

•
•

•

•
•
•
•

•

•
•

•
•
•

•
•

•
•
•

•

•
•

•

•

•

•

•
•
•
•

•

•

•
•
•

•
•

•
•
•

•
•

•

•

•

•
•
•
•
•
•
•
•
•
•
•

•
•

•

•

•

•

•
•

•

•

•

•

•

•
•
•
•
•

•

•

•

•

•
•

•
•

••

•
•

•

•

•
•

•

•

•

•
•

•
•

•

•

•

•

•
•

•
•

•

•

•
••

•

•
•

•

•
•
•
•

•

•

•

•
•
•
•

•

•

•
•
•

•

•

•

•

•
•

•

•

•
•
•

•

•

•

•

•

•

•

•

•
•

•
•
•

•

•

•

•
•
•

•
•
•
•

•

•
•
•

•

•

•
•
•
•

•
•
•

••

•

•
•
•
•

•

•
•

•

•
•

•

•
•
•
•
•

•

•
•

•

•

•
•

•

•
•
•
•

•

•
•

•
•
•

•
•

•
•
•

•

•
•

•

•

•

•

•
•
•
•

•

•

•
•
•

FIGURE 8.12. Data with two features and two classes, separated by a linear
boundary. (Left panel:) Decision boundary estimated from bagging the decision
rule from a single split, axis-oriented classiﬁer. (Right panel:) Decision boundary
from boosting the decision rule of the same classiﬁer. The test error rates are
0.166, and 0.065, respectively. Boosting is described in Chapter 10.

and is described in Chapter 10. The decision boundary in the right panel is
the result of the boosting procedure, and it roughly captures the diagonal
boundary.

8.8 Model Averaging and Stacking

In Section 8.4 we viewed bootstrap values of an estimator as approximate
posterior values of a corresponding parameter, from a kind of nonparamet-
ric Bayesian analysis. Viewed in this way, the bagged estimate (8.51) is
an approximate posterior Bayesian mean. In contrast, the training sample
estimate ˆf (x) corresponds to the mode of the posterior. Since the posterior
mean (not mode) minimizes squared-error loss, it is not surprising that
bagging can often reduce mean squared-error.

Here we discuss Bayesian model averaging more generally. We have a
Mm, m = 1, . . . , M for our training set Z. These
set of candidate models
models may be of the same type with diﬀerent parameter values (e.g.,
subsets in linear regression), or diﬀerent models for the same task (e.g.,
neural networks and regression trees).

Suppose ζ is some quantity of interest, for example, a prediction f (x) at

some ﬁxed feature value x. The posterior distribution of ζ is

Z) =

Pr(ζ

|

M

m=1
X

Pr(ζ

|Mm, Z)Pr(

Mm|

Z),

(8.53)

8.8 Model Averaging and Stacking

289

with posterior mean

Z) =

E(ζ

|

M

m=1
X

E(ζ

|Mm, Z)Pr(

Mm|

Z).

(8.54)

This Bayesian prediction is a weighted average of the individual predictions,
with weights proportional to the posterior probability of each model.

This formulation leads to a number of diﬀerent model-averaging strate-
gies. Committee methods take a simple unweighted average of the predic-
tions from each model, essentially giving equal probability to each model.
More ambitiously, the development in Section 7.7 shows the BIC criterion
can be used to estimate posterior model probabilities. This is applicable
in cases where the diﬀerent models arise from the same parametric model,
with diﬀerent parameter values. The BIC gives weight to each model de-
pending on how well it ﬁts and how many parameters it uses. One can also
carry out the Bayesian recipe in full. If each model
Mm has parameters
θm, we write

Pr(

Z)

Mm|

Pr(

Pr(

Mm)
Mm)

·

·

∝

∝

Pr(Z

|Mm)
θm,
|

Pr(Z

Z

Mm)Pr(θm|Mm)dθm.

(8.55)

In principle one can specify priors Pr(θm|Mm) and numerically com-
pute the posterior probabilities from (8.55), to be used as model-averaging
weights. However, we have seen no real evidence that this is worth all of
the eﬀort, relative to the much simpler BIC approximation.

How can we approach model averaging from a frequentist viewpoint?
Given predictions ˆf1(x), ˆf2(x), . . . , ˆfM (x), under squared-error loss, we can
seek the weights w = (w1, w2, . . . , wM ) such that

ˆw = argmin

w

M

EP

Y

h

−

m=1
X

wm ˆfm(x)

2

.

i

(8.56)

Here the input value x is ﬁxed and the N observations in the dataset Z (and
. The solution is the population
the target Y ) are distributed according to
linear regression of Y on ˆF (x)T

[ ˆf1(x), ˆf2(x), . . . , ˆfM (x)]:

P

≡

ˆw = EP [ ˆF (x) ˆF (x)T ]−1EP [ ˆF (x)Y ].

(8.57)

Now the full regression has smaller error than any single model

EP

Y

"

−

M

m=1
X

ˆwm ˆfm(x)

2

≤

#

EP

Y

h

ˆfm(x)

−

2

i

m

∀

(8.58)

so combining models never makes things worse, at the population level.

290

8. Model Inference and Averaging

Of course the population linear regression (8.57) is not available, and it
is natural to replace it with the linear regression over the training set. But
there are simple examples where this does not work well. For example, if
ˆfm(x), m = 1, 2, . . . , M represent the prediction from the best subset of
inputs of size m among M total inputs, then linear regression would put all
of the weight on the largest model, that is, ˆwM = 1, ˆwm = 0, m < M . The
problem is that we have not put each of the models on the same footing
by taking into account their complexity (the number of inputs m in this
example).

Stacked generalization, or stacking, is a way of doing this. Let ˆf −i
m (x)
be the prediction at x, using model m, applied to the dataset with the
ith training observation removed. The stacking estimate of the weights is
obtained from the least squares linear regression of yi on ˆf −i
m (xi), m =
1, 2, . . . , M . In detail the stacking weights are given by
2

N

M

(8.59)

ˆwst = argmin

yi −

wm ˆf −i

m (xi)

.

w

m=1
X

i=1"
X
m ˆwst
m

#
ˆfm(x). By using the cross-validated pre-
The ﬁnal prediction is
dictions ˆf −i
m (x), stacking avoids giving unfairly high weight to models with
higher complexity. Better results can be obtained by restricting the weights
to be nonnegative, and to sum to 1. This seems like a reasonable restriction
if we interpret the weights as posterior model probabilities as in equation
(8.54), and it leads to a tractable quadratic programming problem.

P

There is a close connection between stacking and model selection via
leave-one-out cross-validation (Section 7.10). If we restrict the minimization
in (8.59) to weight vectors w that have one unit weight and the rest zero,
this leads to a model choice ˆm with smallest leave-one-out cross-validation
error. Rather than choose a single model, stacking combines them with
estimated optimal weights. This will often lead to better prediction, but
less interpretability than the choice of only one of the M models.

The stacking idea is actually more general than described above. One
can use any learning method, not just linear regression, to combine the
models as in (8.59); the weights could also depend on the input location
x. In this way, learning methods are “stacked” on top of one another, to
improve prediction performance.

8.9 Stochastic Search: Bumping

The ﬁnal method described in this chapter does not involve averaging or
combining models, but rather is a technique for ﬁnding a better single
model. Bumping uses bootstrap sampling to move randomly through model
space. For problems where ﬁtting method ﬁnds many local minima, bump-
ing can help the method to avoid getting stuck in poor solutions.

8.9 Stochastic Search: Bumping

291

Regular 4-Node Tree

Bumped 4-Node Tree

•

•
• •
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•

•

•

•

•
•
•
•

•
•

•
•
•
•

•
•
•
•
•
•
•

•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•

•

•

•
•

•
•
•
•
•

•

••
•
•
•

•

•
•
•
•
•

•

•

•
•
•

•

•
•
•

•

•

•
•
•
•
•

•
•
•
•
•
•

•

•
•
•
•
•
•
•
•
•
•
•
•

•

•
•
•

•

•

•

•

•

•
•

•

•

•
•

•

•

•
•

•
•
•
•
•
•
•
•

•

•
•
•

•
•
•

•

•

•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•

•

•
•

•
•

•
•
•

•
•

•
•

•

•
•
•

•
•
•
•

•

•

•

•

•

•
•
•

•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•

•

•

•
•

•

•

•
•

•
•

•

•

•

•
•
•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•

•

•
••
•
•
•
•
•
•

•

•

•
•
•
•
•
•
•
•

•
•

•

•

•

•

•

•

•

•

•

•
•
•
•
•
•
•
•
•

•
•
•

•
•
•

•

•
•

•

•
•
•

•

•
•

•
•
•

•
•
•
•

•
•
•

•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•
•

•
•
•
•

•
•

•
•
•

•

•
•
•

•

•

•
• •
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•

•

•

•

•
•
•
•

•
•

•
•
•
•

•
•
•
•
•
•
•

•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•

•

•

•
•

•
•
•
•
•

•

••
•
•
•

•

•
•
•
•
•

•

•

•
•
•

•

•
•
•

•

•

•
•
•
•
•

•
•
•
•
•
•

•

•
•
•
•
•
•
•
•
•
•
•
•

•

•
•
•

•

•

•

•

•

•
•

•

•

•
•

•

•

•
•

•
•
•
•
•
•
•
•

•

•
•
•

•
•
•

•

•

•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•

•

•
•

•
•

•
•
•

•
•

•
•

•

•
•
•

•
•
•
•

•

•

•

•

•

•
•
•

•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•

•

•

•
•

•

•

•
•

•
•

•

•

•

•
•
•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•

•

•
••
•
•
•
•
•
•

•

•

•
•
•
•
•
•
•
•

•
•

•

•

•

•

•

•

•

•

•

•
•
•
•
•
•
•
•
•

•
•
•

•
•
•

•

•
•

•

•
•
•

•

•
•

•
•
•

•
•
•
•

•
•
•

•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•
•

•
•
•
•

•
•

•
•
•

•

•
•
•

•

FIGURE 8.13. Data with two features and two classes (blue and orange), dis-
playing a pure interaction. The left panel shows the partition found by three splits
of a standard, greedy, tree-growing algorithm. The vertical grey line near the left
edge is the ﬁrst split, and the broken lines are the two subsequent splits. The al-
gorithm has no idea where to make a good initial split, and makes a poor choice.
The right panel shows the near-optimal splits found by bumping the tree-growing
algorithm 20 times.

As in bagging, we draw bootstrap samples and ﬁt a model to each. But
rather than average the predictions, we choose the model estimated from a
bootstrap sample that best ﬁts the training data. In detail, we draw boot-
strap samples Z∗1, . . . , Z∗B and ﬁt our model to each, giving predictions
ˆf ∗b(x), b = 1, 2, . . . , B at input point x. We then choose the model that
produces the smallest prediction error, averaged over the original training
set. For squared error, for example, we choose the model obtained from
bootstrap sample ˆb, where

ˆb = arg min

b

N

[yi −

i=1
X

ˆf ∗b(xi)]2.

(8.60)

The corresponding model predictions are ˆf ∗ˆb(x). By convention we also
include the original training sample in the set of bootstrap samples, so that
the method is free to pick the original model if it has the lowest training
error.

By perturbing the data, bumping tries to move the ﬁtting procedure
around to good areas of model space. For example, if a few data points are
causing the procedure to ﬁnd a poor solution, any bootstrap sample that
omits those data points should procedure a better solution.

For another example, consider the classiﬁcation data in Figure 8.13, the
notorious exclusive or (XOR) problem. There are two classes (blue and
orange) and two input features, with the features exhibiting a pure inter-

292

8. Model Inference and Averaging

action. By splitting the data at x1 = 0 and then splitting each resulting
strata at x2 = 0, (or vice versa) a tree-based classiﬁer could achieve per-
fect discrimination. However, the greedy, short-sighted CART algorithm
(Section 9.2) tries to ﬁnd the best split on either feature, and then splits
the resulting strata. Because of the balanced nature of the data, all initial
splits on x1 or x2 appear to be useless, and the procedure essentially gener-
ates a random split at the top level. The actual split found for these data is
shown in the left panel of Figure 8.13. By bootstrap sampling from the data,
bumping breaks the balance in the classes, and with a reasonable number
of bootstrap samples (here 20), it will by chance produce at least one tree
with initial split near either x1 = 0 or x2 = 0. Using just 20 bootstrap
samples, bumping found the near optimal splits shown in the right panel
of Figure 8.13. This shortcoming of the greedy tree-growing algorithm is
exacerbated if we add a number of noise features that are independent of
the class label. Then the tree-growing algorithm cannot distinguish x1 or
x2 from the others, and gets seriously lost.

Since bumping compares diﬀerent models on the training data, one must
ensure that the models have roughly the same complexity. In the case of
trees, this would mean growing trees with the same number of terminal
nodes on each bootstrap sample. Bumping can also help in problems where
it is diﬃcult to optimize the ﬁtting criterion, perhaps because of a lack of
smoothness. The trick is to optimize a diﬀerent, more convenient criterion
over the bootstrap samples, and then choose the model producing the best
results for the desired criterion on the training sample.

Bibliographic Notes

There are many books on classical statistical inference: Cox and Hink-
ley (1974) and Silvey (1975) give nontechnical accounts. The bootstrap
is due to Efron (1979) and is described more fully in Efron and Tibshi-
rani (1993) and Hall (1992). A good modern book on Bayesian inference
is Gelman et al. (1995). A lucid account of the application of Bayesian
methods to neural networks is given in Neal (1996). The statistical appli-
cation of Gibbs sampling is due to Geman and Geman (1984), and Gelfand
and Smith (1990), with related work by Tanner and Wong (1987). Markov
chain Monte Carlo methods, including Gibbs sampling and the Metropolis–
Hastings algorithm, are discussed in Spiegelhalter et al. (1996). The EM
algorithm is due to Dempster et al. (1977); as the discussants in that pa-
per make clear, there was much related, earlier work. The view of EM as
a joint maximization scheme for a penalized complete-data log-likelihood
was elucidated by Neal and Hinton (1998); they credit Csiszar and Tusn´ady
(1984) and Hathaway (1986) as having noticed this connection earlier. Bag-
ging was proposed by Breiman (1996a). Stacking is due to Wolpert (1992);

Exercises

293

Breiman (1996b) contains an accessible discussion for statisticians. Leblanc
and Tibshirani (1996) describe variations on stacking based on the boot-
strap. Model averaging in the Bayesian framework has been recently advo-
cated by Madigan and Raftery (1994). Bumping was proposed by Tibshi-
rani and Knight (1999).

Exercises

Ex. 8.1 Let r(y) and q(y) be probability density functions. Jensen’s in-
equality states that for a random variable X and a convex function φ(x),
E[φ(X)]

φ[E(X)]. Use Jensen’s inequality to show that

≥

Eq log[r(Y )/q(Y )]

(8.61)

is maximized as a function of r(y) when r(y) = q(y). Hence show that
R(θ, θ)

R(θ′, θ) as stated below equation (8.46).

≥

Ex. 8.2 Consider the maximization of the log-likelihood (8.48), over dis-
Zm ˜P (Zm) = 1. Use La-
tributions ˜P (Zm) such that ˜P (Zm)
≥
grange multipliers to show that the solution is the conditional distribution
˜P (Zm) = Pr(Zm

Z, θ′), as in (8.49).

0 and

P

|

Ex. 8.3 Justify the estimate (8.50), using the relationship

Pr(A) =

Pr(A
|

Z

B)d(Pr(B)).

Ex. 8.4 Consider the bagging method of Section 8.7. Let our estimate ˆf (x)
be the B-spline smoother ˆµ(x) of Section 8.2.1. Consider the parametric
bootstrap of equation (8.6), applied to this estimator. Show that if we bag
ˆf (x), using the parametric bootstrap to generate the bootstrap samples,
the bagging estimate ˆfbag(x) converges to the original estimate ˆf (x) as
B

.

→ ∞

Ex. 8.5 Suggest generalizations of each of the loss functions in Figure 10.4
to more than two classes, and design an appropriate plot to compare them.

Ex. 8.6 Consider the bone mineral density data of Figure 5.6.

(a) Fit a cubic smooth spline to the relative change in spinal BMD, as a
function of age. Use cross-validation to estimate the optimal amount
of smoothing. Construct pointwise 90% conﬁdence bands for the un-
derlying function.

(b) Compute the posterior mean and covariance for the true function via
(8.28), and compare the posterior bands to those obtained in (a).

294

8. Model Inference and Averaging

(c) Compute 100 bootstrap replicates of the ﬁtted curves, as in the bottom
left panel of Figure 8.2. Compare the results to those obtained in (a)
and (b).

Ex. 8.7 EM as a minorization algorithm(Hunter and Lange, 2004; Wu and
Lange, 2007). A function g(x, y) to said to minorize a function f (x) if

g(x, y)

≤

f (x), g(x, x) = f (x)

(8.62)

for all x, y in the domain. This is useful for maximizing f (x) since it is easy
to show that f (x) is non-decreasing under the update

xs+1 = argmaxxg(x, xs)

(8.63)

There are analogous deﬁnitions for majorization, for minimizing a function
f (x). The resulting algorithms are known as MM algorithms, for “Minorize-
Maximize” or “Majorize-Minimize.”

Show that the EM algorithm (Section 8.5.2) is an example of an MM al-
gorithm, using Q(θ′, θ)+log Pr(Z
Q(θ, θ) to minorize the observed data
−
log-likelihood ℓ(θ′; Z). (Note that only the ﬁrst term involves the relevant
parameter θ′).

θ)

|

This is page 295
Printer: Opaque this

9
Additive Models, Trees, and Related
Methods

In this chapter we begin our discussion of some speciﬁc methods for super-
vised learning. These techniques each assume a (diﬀerent) structured form
for the unknown regression function, and by doing so they ﬁnesse the curse
of dimensionality. Of course, they pay the possible price of misspecifying
the model, and so in each case there is a tradeoﬀ that has to be made. They
take oﬀ where Chapters 3–6 left oﬀ. We describe ﬁve related techniques:
generalized additive models, trees, multivariate adaptive regression splines,
the patient rule induction method, and hierarchical mixtures of experts.

9.1 Generalized Additive Models

Regression models play an important role in many data analyses, providing
prediction and classiﬁcation rules, and data analytic tools for understand-
ing the importance of diﬀerent inputs.

Although attractively simple, the traditional linear model often fails in
these situations: in real life, eﬀects are often not linear. In earlier chapters
we described techniques that used predeﬁned basis functions to achieve
nonlinearities. This section describes more automatic ﬂexible statistical
methods that may be used to identify and characterize nonlinear regression
eﬀects. These methods are called “generalized additive models.”

In the regression setting, a generalized additive model has the form

E(Y

|

X1, X2, . . . , Xp) = α + f1(X1) + f2(X2) +

+ fp(Xp).

(9.1)

· · ·

296

9. Additive Models, Trees, and Related Methods

As usual X1, X2, . . . , Xp represent predictors and Y is the outcome; the fj’s
are unspeciﬁed smooth (“nonparametric”) functions. If we were to model
each function using an expansion of basis functions (as in Chapter 5), the
resulting model could then be ﬁt by simple least squares. Our approach
here is diﬀerent: we ﬁt each function using a scatterplot smoother (e.g., a
cubic smoothing spline or kernel smoother), and provide an algorithm for
simultaneously estimating all p functions (Section 9.1.1).

For two-class classiﬁcation, recall the logistic regression model for binary
data discussed in Section 4.4. We relate the mean of the binary response
X) to the predictors via a linear regression model and
µ(X) = Pr(Y = 1
|
the logit link function:

log

µ(X)

1

(cid:18)

−

µ(X)

(cid:19)

= α + β1X1 +

+ βpXp.

· · ·

(9.2)

The additive logistic regression model replaces each linear term by a more

general functional form

log

µ(X)

1

(cid:18)

−

µ(X)

(cid:19)

= α + f1(X1) +

+ fp(Xp),

· · ·

(9.3)

where again each fj is an unspeciﬁed smooth function. While the non-
parametric form for the functions fj makes the model more ﬂexible, the
additivity is retained and allows us to interpret the model in much the
same way as before. The additive logistic regression model is an example
of a generalized additive model. In general, the conditional mean µ(X) of
a response Y is related to an additive function of the predictors via a link
function g:

Examples of classical link functions are the following:

g[µ(X)] = α + f1(X1) +

+ fp(Xp).

(9.4)

· · ·

•

•

•

g(µ) = µ is the identity link, used for linear and additive models for
Gaussian response data.

g(µ) = logit(µ) as above, or g(µ) = probit(µ), the probit link function,
for modeling binomial probabilities. The probit function is the inverse
Gaussian cumulative distribution function: probit(µ) = Φ−1(µ).

g(µ) = log(µ) for log-linear or log-additive models for Poisson count
data.

All three of these arise from exponential family sampling models, which
in addition include the gamma and negative-binomial distributions. These
families generate the well-known class of generalized linear models, which
are all extended in the same way to generalized additive models.

The functions fj are estimated in a ﬂexible manner, using an algorithm
whose basic building block is a scatterplot smoother. The estimated func-
tion ˆfj can then reveal possible nonlinearities in the eﬀect of Xj. Not all

9.1 Generalized Additive Models

297

of the functions fj need to be nonlinear. We can easily mix in linear and
other parametric forms with the nonlinear terms, a necessity when some of
the inputs are qualitative variables (factors). The nonlinear terms are not
restricted to main eﬀects either; we can have nonlinear components in two
or more variables, or separate curves in Xj for each level of the factor Xk.
Thus each of the following would qualify:

g(µ) = X T β + αk + f (Z)—a semiparametric model, where X is a
vector of predictors to be modeled linearly, αk the eﬀect for the kth
level of a qualitative input V , and the eﬀect of predictor Z is modeled
nonparametrically.

g(µ) = f (X) + gk(Z)—again k indexes the levels of a qualitative
input V , and thus creates an interaction term g(V, Z) = gk(Z) for
the eﬀect of V and Z.

g(µ) = f (X) + g(Z, W ) where g is a nonparametric function in two
features.

•

•

•

Additive models can replace linear models in a wide variety of settings,

for example an additive decomposition of time series,

Yt = St + Tt + εt,

(9.5)

where St is a seasonal component, Tt is a trend and ε is an error term.

9.1.1 Fitting Additive Models

In this section we describe a modular algorithm for ﬁtting additive models
and their generalizations. The building block is the scatterplot smoother
for ﬁtting nonlinear eﬀects in a ﬂexible way. For concreteness we use as our
scatterplot smoother the cubic smoothing spline described in Chapter 5.

The additive model has the form

p

Y = α +

fj(Xj) + ε,

(9.6)

j=1
X

where the error term ε has mean zero. Given observations xi, yi, a criterion
like the penalized sum of squares (5.9) of Section 5.4 can be speciﬁed for
this problem,

PRSS(α, f1, f2, . . . , fp) =

N

p

α

yi −

−

fj(xij)

!

j=1
X

i=1 
X

2

p

+

λj

′′

j (tj)2dtj,

f

j=1
X

Z

(9.7)
0 are tuning parameters. It can be shown that the minimizer
where the λj ≥
of (9.7) is an additive cubic spline model; each of the functions fj is a

298

9. Additive Models, Trees, and Related Methods

Algorithm 9.1 The Backﬁtting Algorithm for Additive Models.

1. Initialize: ˆα = 1
N

N

1 yi, ˆfj ≡

0,

∀

i, j.

P
2. Cycle: j = 1, 2, . . . , p, . . . , 1, 2, . . . , p, . . . ,

ˆfj ← Sj

yi −

"{

ˆα

ˆfj ←

ˆfj −

1
N

N

i=1
X

N
1
}

,

#

ˆfk(xik)

−

Xk6=j
ˆfj(xij).

until the functions ˆfj change less than a prespeciﬁed threshold.

cubic spline in the component Xj, with knots at each of the unique values
of xij, i = 1, . . . , N . However, without further restrictions on the model,
the solution is not unique. The constant α is not identiﬁable, since we
can add or subtract any constants to each of the functions fj, and adjust
N
α accordingly. The standard convention is to assume that
1 fj(xij) =
0
j—the functions average zero over the data. It is easily seen that ˆα =
ave(yi) in this case. If in addition to this restriction, the matrix of input
values (having ijth entry xij) has full column rank, then (9.7) is a strictly
convex criterion and the minimizer is unique. If the matrix is singular, then
the linear part of the components fj cannot be uniquely determined (while
the nonlinear parts can!)(Buja et al., 1989).

P

∀

Sj to the targets

Furthermore, a simple iterative procedure exists for ﬁnding the solution.
We set ˆα = ave(yi), and it never changes. We apply a cubic smoothing
N
1 , as a function of xij,
spline
}
−
to obtain a new estimate ˆfj. This is done for each predictor in turn, using
P
the current estimates of the other functions ˆfk when computing yi −
−
ˆfk(xik). The process is continued until the estimates ˆfj stabilize. This
procedure, given in detail in Algorithm 9.1, is known as “backﬁtting” and
P
the resulting ﬁt is analogous to a multiple regression for linear models.

ˆfk(xik)

yi −
{

k6=j

k6=j

ˆα

ˆα

In principle, the second step in (2) of Algorithm 9.1 is not needed, since
the smoothing spline ﬁt to a mean-zero response has mean zero (Exer-
cise 9.1). In practice, machine rounding can cause slippage, and the ad-
justment is advised.

This same algorithm can accommodate other ﬁtting methods in exactly

the same way, by specifying appropriate smoothing operators

Sj:

•

other univariate regression smoothers such as local polynomial re-
gression and kernel methods;

9.1 Generalized Additive Models

299

•

linear regression operators yielding polynomial ﬁts, piecewise con-
stant ﬁts, parametric spline ﬁts, series and Fourier ﬁts;

•

more complicated operators such as surface smoothers for second or
higher-order interactions or periodic smoothers for seasonal eﬀects.
If we consider the operation of smoother
Sj only at the training points, it
N operator matrix Sj (see Section 5.4.1).
can be represented by an N
Then the degrees of freedom for the jth term are (approximately) computed
as df j = trace[Sj]
1, by analogy with degrees of freedom for smoothers
discussed in Chapters 5 and 6.

×

−

For a large class of linear smoothers Sj, backﬁtting is equivalent to a
Gauss–Seidel algorithm for solving a certain linear system of equations.
Details are given in Exercise 9.2.

For the logistic regression model and other generalized additive models,
the appropriate criterion is a penalized log-likelihood. To maximize it, the
backﬁtting procedure is used in conjunction with a likelihood maximizer.
The usual Newton–Raphson routine for maximizing log-likelihoods in gen-
eralized linear models can be recast as an IRLS (iteratively reweighted
least squares) algorithm. This involves repeatedly ﬁtting a weighted linear
regression of a working response variable on the covariates; each regression
yields a new value of the parameter estimates, which in turn give new work-
ing responses and weights, and the process is iterated (see Section 4.4.1).
In the generalized additive model, the weighted linear regression is simply
replaced by a weighted backﬁtting algorithm. We describe the algorithm in
more detail for logistic regression below, and more generally in Chapter 6
of Hastie and Tibshirani (1990).

9.1.2 Example: Additive Logistic Regression

Probably the most widely used model in medical research is the logistic
model for binary data. In this model the outcome Y can be coded as 0
or 1, with 1 indicating an event (like death or relapse of a disease) and
0 indicating no event. We wish to model Pr(Y = 1
X), the probability of
|
an event given values of the prognostic factors X T = (X1, . . . , Xp). The
goal is usually to understand the roles of the prognostic factors, rather
than to classify new individuals. Logistic models are also used in applica-
tions where one is interested in estimating the class probabilities, for use
in risk screening. Apart from medical applications, credit risk screening is
a popular application.

The generalized additive logistic model has the form

log

Pr(Y = 1
|
Pr(Y = 0
|

X)
X)

= α + f1(X1) +

+ fp(Xp).

· · ·

(9.8)

The functions f1, f2, . . . , fp are estimated by a backﬁtting algorithm

within a Newton–Raphson procedure, shown in Algorithm 9.2.

300

9. Additive Models, Trees, and Related Methods

Algorithm 9.2 Local Scoring Algorithm for the Additive Logistic Regres-
sion Model.

1. Compute starting values: ˆα = log[¯y/(1
¯y)], where ¯y = ave(yi), the
−
sample proportion of ones, and set ˆfj ≡
0

j.

∀

2. Deﬁne ˆηi = ˆα +

Iterate:

j

P

ˆfj(xij) and ˆpi = 1/[1 + exp(

ˆηi)].

−

(a) Construct the working target variable

zi = ˆηi +

(yi −
ˆpi(1
−

ˆpi)
ˆpi)

.

(b) Construct weights wi = ˆpi(1
−
(c) Fit an additive model to the targets zi with weights wi, us-
ing a weighted backﬁtting algorithm. This gives new estimates
ˆα, ˆfj,

ˆpi)

j

∀

3. Continue step 2. until the change in the functions falls below a pre-

speciﬁed threshold.

The additive model ﬁtting in step (2) of Algorithm 9.2 requires a weighted
scatterplot smoother. Most smoothing procedures can accept observation
weights (Exercise 5.12); see Chapter 3 of Hastie and Tibshirani (1990) for
further details.

The additive logistic regression model can be generalized further to han-
dle more than two classes, using the multilogit formulation as outlined in
Section 4.4. While the formulation is a straightforward extension of (9.8),
the algorithms for ﬁtting such models are more complex. See Yee and Wild
(1996) for details, and the VGAM software currently available from:

http://www.stat.auckland.ac.nz/

∼

yee.

Example: Predicting Email Spam

We apply a generalized additive model to the spam data introduced in
Chapter 1. The data consists of information from 4601 email messages, in
a study to screen email for “spam” (i.e., junk email). The data is publicly
available at ftp.ics.uci.edu, and was donated by George Forman from
Hewlett-Packard laboratories, Palo Alto, California.

The response variable is binary, with values email or spam, and there are

57 predictors as described below:

•

48 quantitative predictors—the percentage of words in the email that
match a given word. Examples include business, address, internet,

9.1 Generalized Additive Models

301

TABLE 9.1. Test data confusion matrix for the additive logistic regression model
ﬁt to the spam training data. The overall test error rate is 5.5%.

True Class
email (0)
spam (1)

Predicted Class

email (0)
58.3%
3.0%

spam (1)
2.5%
36.3%

free, and george. The idea was that these could be customized for
individual users.

6 quantitative predictors—the percentage of characters in the email
that match a given character. The characters are ch;, ch(, ch[, ch!,
ch$, and ch#.

The average length of uninterrupted sequences of capital letters:
CAPAVE.

The length of the longest uninterrupted sequence of capital letters:
CAPMAX.

The sum of the length of uninterrupted sequences of capital letters:
CAPTOT.

•

•

•

•

We coded spam as 1 and email as zero. A test set of size 1536 was randomly
chosen, leaving 3065 observations in the training set. A generalized additive
model was ﬁt, using a cubic smoothing spline with a nominal four degrees of
freedom for each predictor. What this means is that for each predictor Xj,
the smoothing-spline parameter λj was chosen so that trace[Sj(λj)]
1 = 4,
where Sj(λ) is the smoothing spline operator matrix constructed using the
observed values xij, i = 1, . . . , N . This is a convenient way of specifying
the amount of smoothing in such a complex model.

−

Most of the spam predictors have a very long-tailed distribution. Before
ﬁtting the GAM model, we log-transformed each variable (actually log(x +
0.1)), but the plots in Figure 9.1 are shown as a function of the original
variables.

The test error rates are shown in Table 9.1; the overall error rate is 5.3%.
By comparison, a linear logistic regression has a test error rate of 7.6%.
Table 9.2 shows the predictors that are highly signiﬁcant in the additive
model.

For ease of interpretation, in Table 9.2 the contribution for each variable
is decomposed into a linear component and the remaining nonlinear com-
ponent. The top block of predictors are positively correlated with spam,
while the bottom block is negatively correlated. The linear component is a
weighted least squares linear ﬁt of the ﬁtted curve on the predictor, while
the nonlinear part is the residual. The linear component of an estimated

302

9. Additive Models, Trees, and Related Methods

TABLE 9.2. Signiﬁcant predictors from the additive model ﬁt to the spam train-
ing data. The coeﬃcients represent the linear part of ˆfj, along with their standard
errors and Z-score. The nonlinear P-value is for a test of nonlinearity of ˆfj.

Name

Num.

df

Coeﬃcient

Std. Error Z Score Nonlinear
P -value

our
over
remove
internet
free
business
hpl
ch!
ch$
CAPMAX
CAPTOT

hp
george
1999
re
edu

5
6
7
8
16
17
26
52
53
56
57

25
27
37
45
46

3.9
3.9
4.0
4.0
3.9
3.8
3.8
4.0
3.9
3.8
4.0

3.9
3.7
3.8
3.9
4.0

Positive eﬀects
0.566
0.244
0.949
0.524
0.507
0.779
0.045
0.674
1.419
0.247
0.755
Negative eﬀects

0.114
0.195
0.183
0.176
0.127
0.186
0.250
0.128
0.280
0.228
0.165

1.404
5.003
0.672
0.620
1.183

−
−
−
−
−

0.224
0.744
0.191
0.133
0.209

4.970
1.249
5.201
2.974
4.010
4.179
0.181
5.283
5.062
1.080
4.566

6.262
6.722
3.512
4.649
5.647

−
−
−
−
−

0.052
0.004
0.093
0.028
0.065
0.194
0.002
0.164
0.354
0.000
0.063

0.140
0.045
0.011
0.597
0.000

function is summarized by the coeﬃcient, standard error and Z-score; the
latter is the coeﬃcient divided by its standard error, and is considered
signiﬁcant if it exceeds the appropriate quantile of a standard normal dis-
tribution. The column labeled nonlinear P -value is a test of nonlinearity
of the estimated function. Note, however, that the eﬀect of each predictor
is fully adjusted for the entire eﬀects of the other predictors, not just for
their linear parts. The predictors shown in the table were judged signiﬁ-
cant by at least one of the tests (linear or nonlinear) at the p = 0.01 level
(two-sided).

Figure 9.1 shows the estimated functions for the signiﬁcant predictors
appearing in Table 9.2. Many of the nonlinear eﬀects appear to account for
a strong discontinuity at zero. For example, the probability of spam drops
signiﬁcantly as the frequency of george increases from zero, but then does
not change much after that. This suggests that one might replace each of
the frequency predictors by an indicator variable for a zero count, and resort
to a linear logistic model. This gave a test error rate of 7.4%; including the
linear eﬀects of the frequencies as well dropped the test error to 6.6%. It
appears that the nonlinearities in the additive model have an additional
predictive power.

9.1 Generalized Additive Models

303

0

2

4
remove

6

0
1

5

0

5
-

0

5
-

0
1
-

)
t
e
n
r
e
t
n
i
(
ˆf

)
l
p
h
(
ˆf

0

2

6

8

4
10
internet

0

5

10
hp

15

20

0

5

10

hpl

0

5
-

0
1
-

)
u
d
e
(
ˆf

)
e
v
o
m
e
r
(
ˆf

)
p
h
(
ˆf

)
e
r
(
ˆf

0
1

5

0

5
-

0

5
-

0
1
-

5

0

5
-

0
1
-

)
r
u
o
(
ˆf

)
e
e
r
f
(
ˆf

)
e
g
r
o
e
g
(
ˆf

)
!
h
c
(
ˆf

5

0

5
-

0
1

5

0

5
-

5

0

5
-

0
1
-

0
1

5

0

5
-

)
r
e
v
o
(
ˆf

5

0

5
-

0

2

6

4
our

8

0

1

3

2
over

)
s
s
e
n
i
s
u
b
(
ˆf

0
1

5

0

5
-

0

2

4
6
free

8

10

0

2

4
6
business

0

10

20
george

30

)
9
9
9
1
(
ˆf

)
$
h
c
(
ˆf

5

0

5
-

0
1

5

0

5
-

0

2

4
1999

6

0

5

10
re

15

20

0

5

15

10
edu

5

0

5
-

)
X
A
M
P
A
C
(
ˆf

)
T
O
T
P
A
C
(
ˆf

5

0

5
-

0

10

20
ch!

30

0

1

2

3
ch$

4

5

6

0

2000

6000
CAPMAX

10000

0

5000

10000
CAPTOT

15000

FIGURE 9.1. Spam analysis: estimated functions for signiﬁcant predictors. The
rug plot along the bottom of each frame indicates the observed values of the cor-
responding predictor. For many of the predictors the nonlinearity picks up the
discontinuity at zero.

304

9. Additive Models, Trees, and Related Methods

It is more serious to classify a genuine email message as spam, since then
a good email would be ﬁltered out and would not reach the user. We can
alter the balance between the class error rates by changing the losses (see
Section 2.4). If we assign a loss L01 for predicting a true class 0 as class 1,
and L10 for predicting a true class 1 as class 0, then the estimated Bayes
rule predicts class 1 if its probability is greater than L01/(L01 + L10). For
example, if we take L01 = 10, L10 = 1 then the (true) class 0 and class 1
error rates change to 0.8% and 8.7%.

More ambitiously, we can encourage the model to ﬁt better data in the
class 0 by using weights L01 for the class 0 observations and L10 for the
class 1 observations. As above, we then use the estimated Bayes rule to
predict. This gave error rates of 1.2% and 8.0% in (true) class 0 and class 1,
respectively. We discuss below the issue of unequal losses further, in the
context of tree-based models.

After ﬁtting an additive model, one should check whether the inclusion
of some interactions can signiﬁcantly improve the ﬁt. This can be done
“manually,” by inserting products of some or all of the signiﬁcant inputs,
or automatically via the MARS procedure (Section 9.4).

This example uses the additive model in an automatic fashion. As a data
analysis tool, additive models are often used in a more interactive fashion,
adding and dropping terms to determine their eﬀect. By calibrating the
amount of smoothing in terms of df j, one can move seamlessly between
linear models (df j = 1) and partially linear models, where some terms are
modeled more ﬂexibly. See Hastie and Tibshirani (1990) for more details.

9.1.3 Summary

Additive models provide a useful extension of linear models, making them
more ﬂexible while still retaining much of their interpretability. The familiar
tools for modeling and inference in linear models are also available for
additive models, seen for example in Table 9.2. The backﬁtting procedure
for ﬁtting these models is simple and modular, allowing one to choose a
ﬁtting method appropriate for each input variable. As a result they have
become widely used in the statistical community.

However additive models can have limitations for large data-mining ap-
plications. The backﬁtting algorithm ﬁts all predictors, which is not feasi-
ble or desirable when a large number are available. The BRUTO procedure
(Hastie and Tibshirani, 1990, Chapter 9) combines backﬁtting with selec-
tion of inputs, but is not designed for large data-mining problems. There
has also been recent work using lasso-type penalties to estimate sparse ad-
ditive models, for example the COSSO procedure of Lin and Zhang (2006)
and the SpAM proposal of Ravikumar et al. (2008). For large problems a
forward stagewise approach such as boosting (Chapter 10) is more eﬀective,
and also allows for interactions to be included in the model.

9.2 Tree-Based Methods

305

9.2 Tree-Based Methods

9.2.1 Background

Tree-based methods partition the feature space into a set of rectangles, and
then ﬁt a simple model (like a constant) in each one. They are conceptually
simple yet powerful. We ﬁrst describe a popular method for tree-based
regression and classiﬁcation called CART, and later contrast it with C4.5,
a major competitor.

Let’s consider a regression problem with continuous response Y and in-
puts X1 and X2, each taking values in the unit interval. The top left panel
of Figure 9.2 shows a partition of the feature space by lines that are parallel
to the coordinate axes. In each partition element we can model Y with a
diﬀerent constant. However, there is a problem: although each partitioning
line has a simple description like X1 = c, some of the resulting regions are
complicated to describe.

To simplify matters, we restrict attention to recursive binary partitions
like that in the top right panel of Figure 9.2. We ﬁrst split the space into
two regions, and model the response by the mean of Y in each region.
We choose the variable and split-point to achieve the best ﬁt. Then one
or both of these regions are split into two more regions, and this process
is continued, until some stopping rule is applied. For example, in the top
t1
right panel of Figure 9.2, we ﬁrst split at X1 = t1. Then the region X1 ≤
is split at X2 = t2 and the region X1 > t1 is split at X1 = t3. Finally, the
region X1 > t3 is split at X2 = t4. The result of this process is a partition
into the ﬁve regions R1, R2, . . . , R5 shown in the ﬁgure. The corresponding
regression model predicts Y with a constant cm in region Rm, that is,

ˆf (X) =

5

m=1
X

cmI

(X1, X2)
{

.
Rm}

∈

(9.9)

This same model can be represented by the binary tree in the bottom left
panel of Figure 9.2. The full dataset sits at the top of the tree. Observations
satisfying the condition at each junction are assigned to the left branch,
and the others to the right branch. The terminal nodes or leaves of the
tree correspond to the regions R1, R2, . . . , R5. The bottom right panel of
Figure 9.2 is a perspective plot of the regression surface from this model.
For illustration, we chose the node means c1 =
7, c3 = 0, c4 =
2, c5 = 4 to make this plot.

5, c2 =

−

−

A key advantage of the recursive binary tree is its interpretability. The
feature space partition is fully described by a single tree. With more than
two inputs, partitions like that in the top right panel of Figure 9.2 are
diﬃcult to draw, but the binary tree representation works in the same
way. This representation is also popular among medical scientists, perhaps
because it mimics the way that a doctor thinks. The tree stratiﬁes the

306

9. Additive Models, Trees, and Related Methods

t4

R5

R4

R3

2
X

t2

R2

R1

t1

t3

X1

2
X

X1

X1 ≤ t1

|

X2 ≤ t2

X1 ≤ t3

X2 ≤ t4

R1

R2

R3

X2

X1

R4

R5

FIGURE 9.2. Partitions and CART. Top right panel shows a partition of a
two-dimensional feature space by recursive binary splitting, as used in CART,
applied to some fake data. Top left panel shows a general partition that cannot
be obtained from recursive binary splitting. Bottom left panel shows the tree cor-
responding to the partition in the top right panel, and a perspective plot of the
prediction surface appears in the bottom right panel.

9.2 Tree-Based Methods

307

population into strata of high and low outcome, on the basis of patient
characteristics.

9.2.2 Regression Trees

We now turn to the question of how to grow a regression tree. Our data
consists of p inputs and a response, for each of N observations: that is,
(xi, yi) for i = 1, 2, . . . , N , with xi = (xi1, xi2, . . . , xip). The algorithm
needs to automatically decide on the splitting variables and split points,
and also what topology (shape) the tree should have. Suppose ﬁrst that we
have a partition into M regions R1, R2, . . . , RM , and we model the response
as a constant cm in each region:

f (x) =

M

m=1
X

cmI(x

Rm).

∈

(9.10)

If we adopt as our criterion minimization of the sum of squares
(yi −
f (xi))2, it is easy to see that the best ˆcm is just the average of yi in region
Rm:

P

ˆcm = ave(yi|

xi ∈
Now ﬁnding the best binary partition in terms of minimum sum of squares
is generally computationally infeasible. Hence we proceed with a greedy
algorithm. Starting with all of the data, consider a splitting variable j and
split point s, and deﬁne the pair of half-planes

(9.11)

Rm).

R1(j, s) =

X
{

Xj ≤

|

s

}

and R2(j, s) =

Xj > s

X
{

|

.
}

(9.12)

Then we seek the splitting variable j and split point s that solve

min
j, s

min
c1

h

Xxi∈R1(j,s)

(yi −

c1)2 + min
c2

(yi −

c2)2

.

i

Xxi∈R2(j,s)

(9.13)

For any choice j and s, the inner minimization is solved by

ˆc1 = ave(yi|

xi ∈

R1(j, s)) and ˆc2 = ave(yi|

xi ∈

R2(j, s)).

(9.14)

For each splitting variable, the determination of the split point s can
be done very quickly and hence by scanning through all of the inputs,
determination of the best pair (j, s) is feasible.

Having found the best split, we partition the data into the two resulting
regions and repeat the splitting process on each of the two regions. Then
this process is repeated on all of the resulting regions.

How large should we grow the tree? Clearly a very large tree might overﬁt
the data, while a small tree might not capture the important structure.

308

9. Additive Models, Trees, and Related Methods

Tree size is a tuning parameter governing the model’s complexity, and the
optimal tree size should be adaptively chosen from the data. One approach
would be to split tree nodes only if the decrease in sum-of-squares due to the
split exceeds some threshold. This strategy is too short-sighted, however,
since a seemingly worthless split might lead to a very good split below it.
The preferred strategy is to grow a large tree T0, stopping the splitting
process only when some minimum node size (say 5) is reached. Then this
large tree is pruned using cost-complexity pruning, which we now describe.
T0 to be any tree that can be obtained by
pruning T0, that is, collapsing any number of its internal (non-terminal)
nodes. We index terminal nodes by m, with node m representing region
denote the number of terminal nodes in T . Letting
Rm. Let

We deﬁne a subtree T

⊂

T

|

|

Nm = #
xi ∈
{
1
Nm

ˆcm =

,
Rm}
yi,

Xxi∈Rm

Qm(T ) =

1
Nm

ˆcm)2,

(yi −

Xxi∈Rm

(9.15)

we deﬁne the cost complexity criterion

|T |

Cα(T ) =

NmQm(T ) + α

m=1
X

T

|

.

|

(9.16)

T0 to minimize Cα(T ).
The idea is to ﬁnd, for each α, the subtree Tα ⊆
0 governs the tradeoﬀ between tree size and its
The tuning parameter α
≥
goodness of ﬁt to the data. Large values of α result in smaller trees Tα, and
conversely for smaller values of α. As the notation suggests, with α = 0 the
solution is the full tree T0. We discuss how to adaptively choose α below.
For each α one can show that there is a unique smallest subtree Tα that
minimizes Cα(T ). To ﬁnd Tα we use weakest link pruning: we successively
collapse the internal node that produces the smallest per-node increase in
m NmQm(T ), and continue until we produce the single-node (root) tree.
This gives a (ﬁnite) sequence of subtrees, and one can show this sequence
P
must contain Tα. See Breiman et al. (1984) or Ripley (1996) for details.
Estimation of α is achieved by ﬁve- or tenfold cross-validation: we choose
the value ˆα to minimize the cross-validated sum of squares. Our ﬁnal tree
is T ˆα.

9.2.3 Classiﬁcation Trees

If the target is a classiﬁcation outcome taking values 1, 2, . . . , K, the only
changes needed in the tree algorithm pertain to the criteria for splitting
nodes and pruning the tree. For regression we used the squared-error node

9.2 Tree-Based Methods

309

E

n

tr

o

p

y

Gini index

Misclassification error

5
.
0

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

0.0

0.2

0.4

0.6

0.8

1.0

p

FIGURE 9.3. Node impurity measures for two-class classiﬁcation, as a function
of the proportion p in class 2. Cross-entropy has been scaled to pass through
(0.5, 0.5).

impurity measure Qm(T ) deﬁned in (9.15), but this is not suitable for
classiﬁcation. In a node m, representing a region Rm with Nm observations,
let

ˆpmk =

1
Nm

I(yi = k),

Xxi∈Rm
the proportion of class k observations in node m. We classify the obser-
vations in node m to class k(m) = arg maxk ˆpmk, the majority class in
node m. Diﬀerent measures Qm(T ) of node impurity include the following:

Misclassiﬁcation error:

Gini index:

Cross-entropy or deviance:

1
Nm

P
−

i∈Rm

I(yi 6
k6=k′ ˆpmk ˆpmk′ =

P
K
k=1 ˆpmk log ˆpmk.
P

= k(m)) = 1

−
K
k=1 ˆpmk(1

ˆpmk(m).

ˆpmk).

−

−

P

max(p, 1

(9.17)
For two classes, if p is the proportion in the second class, these three mea-
sures are 1
p),
respectively. They are shown in Figure 9.3. All three are similar, but cross-
entropy and the Gini index are diﬀerentiable, and hence more amenable to
numerical optimization. Comparing (9.13) and (9.15), we see that we need
to weight the node impurity measures by the number NmL and NmR of
observations in the two child nodes created by splitting node m.

p), 2p(1

p) log (1

p) and

p log p

(1

−

−

−

−

−

−

In addition, cross-entropy and the Gini index are more sensitive to changes
in the node probabilities than the misclassiﬁcation rate. For example, in
a two-class problem with 400 observations in each class (denote this by
(400, 400)), suppose one split created nodes (300, 100) and (100, 300), while

310

9. Additive Models, Trees, and Related Methods

the other created nodes (200, 400) and (200, 0). Both splits produce a mis-
classiﬁcation rate of 0.25, but the second split produces a pure node and is
probably preferable. Both the Gini index and cross-entropy are lower for the
second split. For this reason, either the Gini index or cross-entropy should
be used when growing the tree. To guide cost-complexity pruning, any of
the three measures can be used, but typically it is the misclassiﬁcation rate.
The Gini index can be interpreted in two interesting ways. Rather than
classify observations to the majority class in the node, we could classify
them to class k with probability ˆpmk. Then the training error rate of this
rule in the node is
k6=k′ ˆpmk ˆpmk′—the Gini index. Similarly, if we code
each observation as 1 for class k and zero otherwise, the variance over the
node of this 0-1 response is ˆpmk(1
ˆpmk). Summing over classes k again
gives the Gini index.

P

−

9.2.4 Other Issues

Categorical Predictors

−

−

When splitting a predictor having q possible unordered values, there are
2q−1
1 possible partitions of the q values into two groups, and the com-
putations become prohibitive for large q. However, with a 0
1 outcome,
this computation simpliﬁes. We order the predictor classes according to the
proportion falling in outcome class 1. Then we split this predictor as if it
were an ordered predictor. One can show this gives the optimal split, in
terms of cross-entropy or Gini index, among all possible 2q−1
1 splits. This
result also holds for a quantitative outcome and square error loss—the cat-
egories are ordered by increasing mean of the outcome. Although intuitive,
the proofs of these assertions are not trivial. The proof for binary outcomes
is given in Breiman et al. (1984) and Ripley (1996); the proof for quantita-
tive outcomes can be found in Fisher (1958). For multicategory outcomes,
no such simpliﬁcations are possible, although various approximations have
been proposed (Loh and Vanichsetakul, 1988).

−

The partitioning algorithm tends to favor categorical predictors with
many levels q; the number of partitions grows exponentially in q, and the
more choices we have, the more likely we can ﬁnd a good one for the data
at hand. This can lead to severe overﬁtting if q is large, and such variables
should be avoided.

The Loss Matrix

In classiﬁcation problems, the consequences of misclassifying observations
are more serious in some classes than others. For example, it is probably
worse to predict that a person will not have a heart attack when he/she
actually will, than vice versa. To account for this, we deﬁne a K
K loss
matrix L, with Lkk′ being the loss incurred for classifying a class k obser-
vation as class k′. Typically no loss is incurred for correct classiﬁcations,

×

9.2 Tree-Based Methods

311

that is, Lkk = 0
k. To incorporate the losses into the modeling process,
∀
we could modify the Gini index to
k6=k′ Lkk′ ˆpmk ˆpmk′; this would be the
expected loss incurred by the randomized rule. This works for the multi-
P
class case, but in the two-class case has no eﬀect, since the coeﬃcient of
ˆpmk ˆpmk′ is Lkk′ + Lk′k. For two classes a better approach is to weight the
observations in class k by Lkk′. This can be used in the multiclass case only
if, as a function of k, Lkk′ doesn’t depend on k′. Observation weighting can
be used with the deviance as well. The eﬀect of observation weighting is to
alter the prior probability on the classes. In a terminal node, the empirical
Bayes rule implies that we classify to class k(m) = arg mink

ℓ Lℓk ˆpmℓ.

Missing Predictor Values

P

Suppose our data has some missing predictor values in some or all of the
variables. We might discard any observation with some missing values, but
this could lead to serious depletion of the training set. Alternatively we
might try to ﬁll in (impute) the missing values, with say the mean of that
predictor over the nonmissing observations. For tree-based models, there
are two better approaches. The ﬁrst is applicable to categorical predictors:
we simply make a new category for “missing.” From this we might dis-
cover that observations with missing values for some measurement behave
diﬀerently than those with nonmissing values. The second more general
approach is the construction of surrogate variables. When considering a
predictor for a split, we use only the observations for which that predictor
is not missing. Having chosen the best (primary) predictor and split point,
we form a list of surrogate predictors and split points. The ﬁrst surrogate
is the predictor and corresponding split point that best mimics the split of
the training data achieved by the primary split. The second surrogate is
the predictor and corresponding split point that does second best, and so
on. When sending observations down the tree either in the training phase
or during prediction, we use the surrogate splits in order, if the primary
splitting predictor is missing. Surrogate splits exploit correlations between
predictors to try and alleviate the eﬀect of missing data. The higher the cor-
relation between the missing predictor and the other predictors, the smaller
the loss of information due to the missing value. The general problem of
missing data is discussed in Section 9.6.

Why Binary Splits?

Rather than splitting each node into just two groups at each stage (as
above), we might consider multiway splits into more than two groups. While
this can sometimes be useful, it is not a good general strategy. The problem
is that multiway splits fragment the data too quickly, leaving insuﬃcient
data at the next level down. Hence we would want to use such splits only
when needed. Since multiway splits can be achieved by a series of binary
splits, the latter are preferred.

312

9. Additive Models, Trees, and Related Methods

Other Tree-Building Procedures

The discussion above focuses on the CART (classiﬁcation and regression
tree) implementation of trees. The other popular methodology is ID3 and
its later versions, C4.5 and C5.0 (Quinlan, 1993). Early versions of the
program were limited to categorical predictors, and used a top-down rule
with no pruning. With more recent developments, C5.0 has become quite
similar to CART. The most signiﬁcant feature unique to C5.0 is a scheme
for deriving rule sets. After a tree is grown, the splitting rules that deﬁne the
terminal nodes can sometimes be simpliﬁed: that is, one or more condition
can be dropped without changing the subset of observations that fall in
the node. We end up with a simpliﬁed set of rules deﬁning each terminal
node; these no longer follow a tree structure, but their simplicity might
make them more attractive to the user.

Linear Combination Splits
s, one can allow splits
Rather than restricting splits to be of the form Xj ≤
s. The weights aj and
ajXj ≤
along linear combinations of the form
split point s are optimized to minimize the relevant criterion (such as the
Gini index). While this can improve the predictive power of the tree, it can
hurt interpretability. Computationally, the discreteness of the split point
search precludes the use of a smooth optimization for the weights. A better
way to incorporate linear combination splits is in the hierarchical mixtures
of experts (HME) model, the topic of Section 9.5.

P

Instability of Trees

One major problem with trees is their high variance. Often a small change
in the data can result in a very diﬀerent series of splits, making interpre-
tation somewhat precarious. The major reason for this instability is the
hierarchical nature of the process: the eﬀect of an error in the top split
is propagated down to all of the splits below it. One can alleviate this to
some degree by trying to use a more stable split criterion, but the inherent
instability is not removed. It is the price to be paid for estimating a simple,
tree-based structure from the data. Bagging (Section 8.7) averages many
trees to reduce this variance.

Lack of Smoothness

Another limitation of trees is the lack of smoothness of the prediction sur-
face, as can be seen in the bottom right panel of Figure 9.2. In classiﬁcation
with 0/1 loss, this doesn’t hurt much, since bias in estimation of the class
probabilities has a limited eﬀect. However, this can degrade performance
in the regression setting, where we would normally expect the underlying
function to be smooth. The MARS procedure, described in Section 9.4,

9.2 Tree-Based Methods

313

TABLE 9.3. Spam data: confusion rates for the 17-node tree (chosen by cross–
validation) on the test data. Overall error rate is 9.3%.

True
email
spam

Predicted

spam
email
4.0%
57.3%
5.3% 33.4%

can be viewed as a modiﬁcation of CART designed to alleviate this lack of
smoothness.

Diﬃculty in Capturing Additive Structure

Another problem with trees is their diﬃculty in modeling additive struc-
ture. In regression, suppose, for example, that Y = c1I(X1 < t1)+c2I(X2 <
t2) + ε where ε is zero-mean noise. Then a binary tree might make its ﬁrst
split on X1 near t1. At the next level down it would have to split both nodes
on X2 at t2 in order to capture the additive structure. This might happen
with suﬃcient data, but the model is given no special encouragement to ﬁnd
such structure. If there were ten rather than two additive eﬀects, it would
take many fortuitous splits to recreate the structure, and the data analyst
would be hard pressed to recognize it in the estimated tree. The “blame”
here can again be attributed to the binary tree structure, which has both
advantages and drawbacks. Again the MARS method (Section 9.4) gives
up this tree structure in order to capture additive structure.

9.2.5 Spam Example (Continued)

We applied the classiﬁcation tree methodology to the spam example intro-
duced earlier. We used the deviance measure to grow the tree and mis-
classiﬁcation rate to prune it. Figure 9.4 shows the 10-fold cross-validation
error rate as a function of the size of the pruned tree, along with
2 stan-
dard errors of the mean, from the ten replications. The test error curve is
shown in orange. Note that the cross-validation error rates are indexed by
a sequence of values of α and not tree size; for trees grown in diﬀerent folds,
a value of α might imply diﬀerent sizes. The sizes shown at the base of the
plot refer to

, the sizes of the pruned original tree.

±

The error ﬂattens out at around 17 terminal nodes, giving the pruned tree
in Figure 9.5. Of the 13 distinct features chosen by the tree, 11 overlap with
the 16 signiﬁcant features in the additive model (Table 9.2). The overall
error rate shown in Table 9.3 is about 50% higher than for the additive
model in Table 9.1.

Consider the rightmost branches of the tree. We branch to the right
with a spam warning if more than 5.5% of the characters are the $ sign.

Tα|

|

314

9. Additive Models, Trees, and Related Methods

176

21

7

5

3

2

0

α

e
t
a
R
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

i

l

4
.
0

3
.
0

2
.
0

1
.
0

0

.

0

0

10

20

30

40

Tree Size

FIGURE 9.4. Results for spam example. The blue curve is the 10-fold cross-val-
idation estimate of misclassiﬁcation rate as a function of tree size, with standard
error bars. The minimum occurs at a tree size with about 17 terminal nodes (using
the “one-standard-error” rule). The orange curve is the test error, which tracks
the CV error quite closely. The cross-validation is indexed by values of α, shown
above. The tree sizes shown below refer to
, the size of the original tree indexed
by α.

Tα

|

|

However, if in addition the phrase hp occurs frequently, then this is likely
to be company business and we classify as email. All of the 22 cases in
the test set satisfying these criteria were correctly classiﬁed. If the second
condition is not met, and in addition the average length of repeated capital
letters CAPAVE is larger than 2.9, then we classify as spam. Of the 227 test
cases, only seven were misclassiﬁed.

In medical classiﬁcation problems, the terms sensitivity and speciﬁcity

are used to characterize a rule. They are deﬁned as follows:

Sensitivity: probability of predicting disease given true state is disease.

Speciﬁcity: probability of predicting non-disease given true state is non-

disease.

 
9.2 Tree-Based Methods

315

email
600/1536

ch$<0.0555

email
280/1177

remove<0.06

ch$>0.0555

spam
 48/359

hp<0.405

remove>0.06

hp>0.405

email
180/1065

spam
  9/112

spam
 26/337

email
  0/22

ch!<0.191

george<0.15

CAPAVE<2.907

ch!>0.191

george>0.15

CAPAVE>2.907

email
 80/861

email
100/204

spam
  6/109

email
  0/3

spam
 19/110

spam
  7/227

george<0.005

CAPAVE<2.7505

1999<0.58

george>0.005

CAPAVE>2.7505

1999>0.58

email
 80/652

email
  0/209

email
 36/123

spam
 16/81

spam
 18/109

email
  0/1

hp<0.03

free<0.065

hp>0.03

free>0.065

email
 77/423

email
  3/229

email
 16/94

spam
  9/29

CAPMAX<10.5

business<0.145

CAPMAX>10.5

business>0.145

email
 20/238

email
 57/185

email
 14/89

spam
  3/5

receive<0.125

edu<0.045

receive>0.125

edu>0.045

email
 19/236

spam
  1/2

email
 48/113

email
  9/72

our<1.2

our>1.2

email
 37/101

spam
  1/12

FIGURE 9.5. The pruned tree for the spam example. The split variables are
shown in blue on the branches, and the classiﬁcation is shown in every node.The
numbers under the terminal nodes indicate misclassiﬁcation rates on the test data.

316

9. Additive Models, Trees, and Related Methods

0
.
1

•
•

•

•

•

•

y
t
i
v
i
t
i
s
n
e
S

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

• •

• • • • •••••••••••••••••••••••••••••••••••••••

•
•
•

•

•

Tree (0.95)
GAM (0.98)
Weighted Tree (0.90)

•
•••
•
•
•

•
•

•
••

•

•

•
•
•

0.0

0.2

0.4

0.6

0.8

1.0

Specificity

FIGURE 9.6. ROC curves for the classiﬁcation rules ﬁt to the spam data. Curves
that are closer to the northeast corner represent better classiﬁers. In this case the
GAM classiﬁer dominates the trees. The weighted tree achieves better sensitivity
for higher speciﬁcity than the unweighted tree. The numbers in the legend repre-
sent the area under the curve.

If we think of spam and email as the presence and absence of disease, re-
spectively, then from Table 9.3 we have

Sensitivity = 100

Speciﬁcity = 100

33.4
33.4 + 5.3
57.3
57.3 + 4.0

×

×

= 86.3%,

= 93.4%.

In this analysis we have used equal losses. As before let Lkk′ be the
loss associated with predicting a class k object as class k′. By varying the
relative sizes of the losses L01 and L10, we increase the sensitivity and
decrease the speciﬁcity of the rule, or vice versa. In this example, we want
to avoid marking good email as spam, and thus we want the speciﬁcity to
be very high. We can achieve this by setting L01 > 1 say, with L10 = 1.
The Bayes’ rule in each terminal node classiﬁes to class 1 (spam) if the
L01/(L10 + L01), and class zero otherwise. The
proportion of spam is

≥

9.3 PRIM: Bump Hunting

317

0.9(1

receiver operating characteristic curve (ROC) is a commonly used summary
for assessing the tradeoﬀ between sensitivity and speciﬁcity. It is a plot of
the sensitivity versus speciﬁcity as we vary the parameters of a classiﬁcation
rule. Varying the loss L01 between 0.1 and 10, and applying Bayes’ rule to
the 17-node tree selected in Figure 9.4, produced the ROC curve shown
in Figure 9.6. The standard error of each curve near 0.9 is approximately
0.9)/1536 = 0.008, and hence the standard error of the diﬀerence
is about 0.01. We see that in order to achieve a speciﬁcity of close to 100%,
p
the sensitivity has to drop to about 50%. The area under the curve is a
commonly used quantitative summary; extending the curve linearly in each
direction so that it is deﬁned over [0, 100], the area is approximately 0.95.
For comparison, we have included the ROC curve for the GAM model ﬁt
to these data in Section 9.2; it gives a better classiﬁcation rule for any loss,
with an area of 0.98.

−

Rather than just modifying the Bayes rule in the nodes, it is better to
take full account of the unequal losses in growing the tree, as was done
in Section 9.2. With just two classes 0 and 1, losses may be incorporated
into the tree-growing process by using weight Lk,1−k for an observation in
class k. Here we chose L01 = 5, L10 = 1 and ﬁt the same size tree as before
(
= 17). This tree has higher sensitivity at high values of the speciﬁcity
Tα|
|
than the original tree, but does more poorly at the other extreme. Its top
few splits are the same as the original tree, and then it departs from it.
For this application the tree grown using L01 = 5 is clearly better than the
original tree.

The area under the ROC curve, used above, is sometimes called the c-
statistic. Interestingly, it can be shown that the area under the ROC curve
is equivalent to the Mann-Whitney U statistic (or Wilcoxon rank-sum test),
for the median diﬀerence between the prediction scores in the two groups
(Hanley and McNeil, 1982). For evaluating the contribution of an additional
predictor when added to a standard model, the c-statistic may not be an
informative measure. The new predictor can be very signiﬁcant in terms
of the change in model deviance, but show only a small increase in the c-
statistic. For example, removal of the highly signiﬁcant term george from
the model of Table 9.2 results in a decrease in the c-statistic of less than
0.01. Instead, it is useful to examine how the additional predictor changes
the classiﬁcation on an individual sample basis. A good discussion of this
point appears in Cook (2007).

9.3 PRIM: Bump Hunting

Tree-based methods (for regression) partition the feature space into box-
shaped regions, to try to make the response averages in each box as diﬀer-

318

9. Additive Models, Trees, and Related Methods

ent as possible. The splitting rules deﬁning the boxes are related to each
through a binary tree, facilitating their interpretation.

The patient rule induction method (PRIM) also ﬁnds boxes in the feature
space, but seeks boxes in which the response average is high. Hence it looks
for maxima in the target function, an exercise known as bump hunting. (If
minima rather than maxima are desired, one simply works with the negative
response values.)

PRIM also diﬀers from tree-based partitioning methods in that the box
deﬁnitions are not described by a binary tree. This makes interpretation of
the collection of rules more diﬃcult; however, by removing the binary tree
constraint, the individual rules are often simpler.

The main box construction method in PRIM works from the top down,
starting with a box containing all of the data. The box is compressed along
one face by a small amount, and the observations then falling outside the
box are peeled oﬀ. The face chosen for compression is the one resulting in
the largest box mean, after the compression is performed. Then the process
is repeated, stopping when the current box contains some minimum number
of data points.

This process is illustrated in Figure 9.7. There are 200 data points uni-
formly distributed over the unit square. The color-coded plot indicates the
response Y taking the value 1 (red) when 0.5 < X1 < 0.8 and 0.4 < X2 <
0.6. and zero (blue) otherwise. The panels shows the successive boxes found
by the top-down peeling procedure, peeling oﬀ a proportion α = 0.1 of the
remaining data points at each stage.

Figure 9.8 shows the mean of the response values in the box, as the box

is compressed.

After the top-down sequence is computed, PRIM reverses the process,
expanding along any edge, if such an expansion increases the box mean.
This is called pasting. Since the top-down procedure is greedy at each step,
such an expansion is often possible.

The result of these steps is a sequence of boxes, with diﬀerent numbers
of observation in each box. Cross-validation, combined with the judgment
of the data analyst, is used to choose the optimal box size.

Denote by B1 the indices of the observations in the box found in step 1.
The PRIM procedure then removes the observations in B1 from the training
set, and the two-step process—top down peeling, followed by bottom-up
pasting—is repeated on the remaining dataset. This entire process is re-
peated several times, producing a sequence of boxes B1, B2, . . . , Bk. Each
box is deﬁned by a set of rules involving a subset of predictors like

(a1 ≤

X1 ≤

b1) and (b1 ≤

X3 ≤

b2).

A summary of the PRIM procedure is given Algorithm 9.3.

PRIM can handle a categorical predictor by considering all partitions of
the predictor, as in CART. Missing values are also handled in a manner
similar to CART. PRIM is designed for regression (quantitative response

9.3 PRIM: Bump Hunting

319

1

2

3

4

5

6

7

8

o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o

o

o

o
o
o
o
o
o
o
oo
o
o
o
o
o

o

o

o
o

o
o

o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o

o

o

o
o
o
o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o

o

o

12

17

22

27

FIGURE 9.7. Illustration of PRIM algorithm. There are two classes, indicated
by the blue (class 0) and red (class 1) points. The procedure starts with a rectangle
(broken black lines) surrounding all of the data, and then peels away points along
one edge by a prespeciﬁed amount in order to maximize the mean of the points
remaining in the box. Starting at the top left panel, the sequence of peelings is
shown, until a pure red region is isolated in the bottom right panel. The iteration
number is indicated at the top of each panel.

•
•
•

•
•
•
•

•

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

n
a
e
M
x
o
B

•••••••••••

•

•

•

•

•

•

•

•

50

100

150

Number of Observations in Box

FIGURE 9.8. Box mean as a function of number of observations in the box.

 
320

9. Additive Models, Trees, and Related Methods

Algorithm 9.3 Patient Rule Induction Method.

1. Start with all of the training data, and a maximal box containing all

of the data.

2. Consider shrinking the box by compressing one face, so as to peel oﬀ
the proportion α of observations having either the highest values of
a predictor Xj, or the lowest. Choose the peeling that produces the
highest response mean in the remaining box. (Typically α = 0.05 or
0.10.)

3. Repeat step 2 until some minimal number of observations (say 10)

remain in the box.

4. Expand the box along any face, as long as the resulting box mean

increases.

5. Steps 1–4 give a sequence of boxes, with diﬀerent numbers of obser-
vations in each box. Use cross-validation to choose a member of the
sequence. Call the box B1.

6. Remove the data in box B1 from the dataset and repeat steps 2–5 to
obtain a second box, and continue to get as many boxes as desired.

variable); a two-class outcome can be handled simply by coding it as 0 and
1. There is no simple way to deal with k > 2 classes simultaneously: one
approach is to run PRIM separately for each class versus a baseline class.
An advantage of PRIM over CART is its patience. Because of its bi-
nary splits, CART fragments the data quite quickly. Assuming splits of
equal size, with N observations it can only make log2(N )
1 splits before
running out of data. If PRIM peels oﬀ a proportion α of training points
at each stage, it can perform approximately
α) peeling
steps before running out of data. For example, if N = 128 and α = 0.10,
then log2(N )
46. Taking into account
log(N )/ log(1
that there must be an integer number of observations at each stage, PRIM
in fact can peel only 29 times. In any case, the ability of PRIM to be more
patient should help the top-down greedy algorithm ﬁnd a better solution.

log(N )/ log(1

1 = 6 while

α)

−

−

≈

−

−

−

−

9.3.1 Spam Example (Continued)

We applied PRIM to the spam data, with the response coded as 1 for spam
and 0 for email.

The ﬁrst two boxes found by PRIM are summarized below:

9.4 MARS: Multivariate Adaptive Regression Splines

321

Rule 1
Training
Test

Rule 2
Training
Test

Global Mean Box Mean Box Support
0.1413
0.1536

0.9607
1.0000

0.3931
0.3958

Rule 1

ch! > 0.029
CAPAVE > 2.331
your > 0.705
1999 < 0.040
CAPTOT > 79.50
edu < 0.070
re < 0.535
ch; < 0.030






Remain Mean Box Mean Box Support
0.1043
0.1061

0.2998
0.2862

0.9560
0.9264

Rule 2

(cid:26)

remove > 0.010
george < 0.110

The box support is the proportion of observations falling in the box.
The ﬁrst box is purely spam, and contains about 15% of the test data.
The second box contains 10.6% of the test observations, 92.6% of which
are spam. Together the two boxes contain 26% of the data and are about
97% spam. The next few boxes (not shown) are quite small, containing only
about 3% of the data.

The predictors are listed in order of importance. Interestingly the top
splitting variables in the CART tree (Figure 9.5) do not appear in PRIM’s
ﬁrst box.

9.4 MARS: Multivariate Adaptive Regression

Splines

MARS is an adaptive procedure for regression, and is well suited for high-
dimensional problems (i.e., a large number of inputs). It can be viewed as a
generalization of stepwise linear regression or a modiﬁcation of the CART
method to improve the latter’s performance in the regression setting. We
introduce MARS from the ﬁrst point of view, and later make the connection
to CART.

MARS uses expansions in piecewise linear basis functions of the form

(x

−

t)+ and (t

−

x)+. The “+” means positive part, so

t)+ =

(x

−

(cid:26)

t,

x

−
0,

if x > t,
otherwise,

and

x)+ =

(t

−

(cid:26)

t

x,

−
0,

if x < t,
otherwise.

322

9. Additive Models, Trees, and Related Methods

n
o
i
t
c
n
u
F

s
i
s
a
B

5
.
0

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

(t − x)+

(x − t)+

0.0

0.2

0.4

0.6

0.8

1.0

t
x

FIGURE 9.9. The basis functions (x
blue) used by MARS.

−

t)+ (solid orange) and (t

x)+ (broken

−

As an example, the functions (x
ure 9.9.

−

0.5)+ and (0.5

−

x)+ are shown in Fig-

Each function is piecewise linear, with a knot at the value t. In the
terminology of Chapter 5, these are linear splines. We call the two functions
a reﬂected pair in the discussion below. The idea is to form reﬂected pairs
for each input Xj with knots at each observed value xij of that input.
Therefore, the collection of basis functions is

=

(Xj −
{

C

t)+, (t

Xj)+} t ∈ {x1j , x2j , . . . , xN j }

j = 1, 2, . . . , p.

−

(9.18)

If all of the input values are distinct, there are 2N p basis functions alto-
gether. Note that although each basis function depends only on a single
Xj, for example, h(X) = (Xj −
t)+, it is considered as a function over the
entire input space IRp.

The model-building strategy is like a forward stepwise linear regression,
but instead of using the original inputs, we are allowed to use functions
from the set

and their products. Thus the model has the form

C

M

f (X) = β0 +

βmhm(X),

(9.19)

where each hm(X) is a function in
functions.

C

m=1
X

, or a product of two or more such

Given a choice for the hm, the coeﬃcients βm are estimated by minimiz-
ing the residual sum-of-squares, that is, by standard linear regression. The
real art, however, is in the construction of the functions hm(x). We start
with only the constant function h0(X) = 1 in our model, and all functions
in the set

are candidate functions. This is depicted in Figure 9.10.

At each stage we consider as a new basis function pair all products of a
. We

with one of the reﬂected pairs in

C

C

function hm in the model set
add to the model

M
ˆβM +1hℓ(X)

M
the term of the form
(Xj −

t)+ + ˆβM +2hℓ(X)

·

(t

Xj)+, hℓ ∈ M

,

−

·

9.4 MARS: Multivariate Adaptive Regression Splines

323

Constant

X2

X2

X1

X1

X2

Xp

X1

X2

Xp

X1

X2

Xp

FIGURE 9.10. Schematic of the MARS forward model-building procedure. On
the left are the basis functions currently in the model: initially, this is the constant
function h(X) = 1. On the right are all candidate basis functions to be considered
in building the model. These are pairs of piecewise linear basis functions as in
Figure 9.9, with knots t at all unique observed values xij of each predictor Xj.
At each stage we consider all products of a candidate pair with a basis function
in the model. The product that decreases the residual error the most is added into
the current model. Above we illustrate the ﬁrst three steps of the procedure, with
the selected functions shown in red.

324

9. Additive Models, Trees, and Related Methods

h(X1, X2)

X2

X1

FIGURE 9.11. The function h(X1, X2) = (X1
from multiplication of two piecewise linear MARS basis functions.

x51)+

(x72

−

−

·

X2)+, resulting

that produces the largest decrease in training error. Here ˆβM +1 and ˆβM +2
are coeﬃcients estimated by least squares, along with all the other M + 1
coeﬃcients in the model. Then the winning products are added to the
model and the process is continued until the model set
contains some
preset maximum number of terms.

M

t)+ + β2(t

For example, at the ﬁrst stage we consider adding to the model a function
of the form β1(Xj −
, since multiplication by
Xj)+; t
the constant function just produces the function itself. Suppose the best
choice is ˆβ1(X2 −
X2)+. Then this pair of basis functions
, and at the next stage we consider including a pair
is added to the set
of products the form

−
x72)+ + ˆβ2(x72 −
M

xij}

∈ {

hm(X)

(Xj −
where for hm we have the choices

and

t)+

·

hm(X)

(t

·

−

Xj)+, t

,
xij}

∈ {

h0(X) = 1,
h1(X) = (X2 −
h2(X) = (x72 −

x72)+, or
X2)+.

The third choice produces functions such as (X1 −
depicted in Figure 9.11.

x51)+ ·

(x72 −

X2)+,

At the end of this process we have a large model of the form (9.19). This
model typically overﬁts the data, and so a backward deletion procedure
is applied. The term whose removal causes the smallest increase in resid-
ual squared error is deleted from the model at each stage, producing an
estimated best model ˆfλ of each size (number of terms) λ. One could use
cross-validation to estimate the optimal value of λ, but for computational

9.4 MARS: Multivariate Adaptive Regression Splines

325

savings the MARS procedure instead uses generalized cross-validation. This
criterion is deﬁned as

GCV(λ) =

N

i=1(yi −
(1
−

P

ˆfλ(xi))2

M (λ)/N )2

.

(9.20)

The value M (λ) is the eﬀective number of parameters in the model: this
accounts both for the number of terms in the models, plus the number
of parameters used in selecting the optimal positions of the knots. Some
mathematical and simulation results suggest that one should pay a price
of three parameters for selecting a knot in a piecewise linear regression.

Thus if there are r linearly independent basis functions in the model, and
K knots were selected in the forward process, the formula is M (λ) = r+cK,
where c = 3. (When the model is restricted to be additive—details below—
a penalty of c = 2 is used). Using this, we choose the model along the
backward sequence that minimizes GCV(λ).

Why these piecewise linear basis functions, and why this particular model
strategy? A key property of the functions of Figure 9.9 is their ability to
operate locally; they are zero over part of their range. When they are mul-
tiplied together, as in Figure 9.11, the result is nonzero only over the small
part of the feature space where both component functions are nonzero. As
a result, the regression surface is built up parsimoniously, using nonzero
components locally—only where they are needed. This is important, since
one should “spend” parameters carefully in high dimensions, as they can
run out quickly. The use of other basis functions such as polynomials, would
produce a nonzero product everywhere, and would not work as well.

The second important advantage of the piecewise linear basis function
concerns computation. Consider the product of a function in
with each
of the N reﬂected pairs for an input Xj. This appears to require the ﬁtting
of N single-input linear regression models, each of which uses O(N ) oper-
ations, making a total of O(N 2) operations. However, we can exploit the
simple form of the piecewise linear function. We ﬁrst ﬁt the reﬂected pair
with rightmost knot. As the knot is moved successively one position at a
time to the left, the basis functions diﬀer by zero over the left part of the
domain, and by a constant over the right part. Hence after each such move
we can update the ﬁt in O(1) operations. This allows us to try every knot
in only O(N ) operations.

M

The forward modeling strategy in MARS is hierarchical, in the sense that
multiway products are built up from products involving terms already in
the model. For example, a four-way product can only be added to the model
if one of its three-way components is already in the model. The philosophy
here is that a high-order interaction will likely only exist if some of its lower-
order “footprints” exist as well. This need not be true, but is a reasonable
working assumption and avoids the search over an exponentially growing
space of alternatives.

326

9. Additive Models, Trees, and Related Methods

r
o
r
r

E
n
o

i
t

a
c
i
f
i
s
s
a
c
s
M

l

i

t
s
e
T

4
0

.

3
0

.

2
0

.

1
0

.

0.055

•

•
••

••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

GCV choice

0

20

40

60

80

100

Rank of Model

FIGURE 9.12. Spam data: test error misclassiﬁcation rate for the MARS pro-
cedure, as a function of the rank (number of independent basis functions) in the
model.

There is one restriction put on the formation of model terms: each input
can appear at most once in a product. This prevents the formation of
higher-order powers of an input, which increase or decrease too sharply
near the boundaries of the feature space. Such powers can be approximated
in a more stable way with piecewise linear functions.

A useful option in the MARS procedure is to set an upper limit on
the order of interaction. For example, one can set a limit of two, allowing
pairwise products of piecewise linear functions, but not three- or higher-
way products. This can aid in the interpretation of the ﬁnal model. An
upper limit of one results in an additive model.

9.4.1 Spam Example (Continued)

We applied MARS to the “spam” data analyzed earlier in this chapter. To
enhance interpretability, we restricted MARS to second-degree interactions.
Although the target is a two-class variable, we used the squared-error loss
function nonetheless (see Section 9.4.3). Figure 9.12 shows the test error
misclassiﬁcation rate as a function of the rank (number of independent ba-
sis functions) in the model. The error rate levels oﬀ at about 5.5%, which is
slightly higher than that of the generalized additive model (5.3%) discussed
earlier. GCV chose a model size of 60, which is roughly the smallest model
giving optimal performance. The leading interactions found by MARS in-
volved inputs (ch$, remove), (ch$, free) and (hp, CAPTOT). However, these
interactions give no improvement in performance over the generalized ad-
ditive model.

 
 
9.4 MARS: Multivariate Adaptive Regression Splines

327

9.4.2 Example (Simulated Data)

Here we examine the performance of MARS in three contrasting scenarios.
There are N = 100 observations, and the predictors X1, X2, . . . , Xp and
errors ε have independent standard normal distributions.

Scenario 1: The data generation model is

Y = (X1 −

1)+ + (X1 −

1)+ ·
The noise standard deviation 0.12 was chosen so that the signal-to-
noise ratio was about 5. We call this the tensor-product scenario; the
product term gives a surface that looks like that of Figure 9.11.

.8)+ + 0.12

(X2 −

(9.21)

ε.

·

Scenario 2: This is the same as scenario 1, but with p = 20 total predictors;
that is, there are 18 inputs that are independent of the response.

Scenario 3: This has the structure of a neural network:

ℓ1 = X1 + X2 + X3 + X4 + X5,
X9 + X10,
ℓ2 = X6 −
Y = σ(ℓ1) + σ(ℓ2) + 0.12

X7 + X8 −

σ(t) = 1/(1 + e−t),

ε.

·

(9.22)

Scenarios 1 and 2 are ideally suited for MARS, while scenario 3 contains
high-order interactions and may be diﬃcult for MARS to approximate. We
ran ﬁve simulations from each model, and recorded the results.

In scenario 1, MARS typically uncovered the correct model almost per-
fectly. In scenario 2, it found the correct structure but also found a few
extraneous terms involving other predictors.
Let µ(x) be the true mean of Y , and let

MSE0 = avex∈Test(¯y
−
MSE = avex∈Test( ˆf (x)

µ(x))2,

µ(x))2.

−

(9.23)

These represent the mean-square error of the constant model and the ﬁtted
MARS model, estimated by averaging at the 1000 test values of x. Table 9.4
shows the proportional decrease in model error or R2 for each scenario:

R2 =

MSE

MSE0 −
MSE0

.

(9.24)

The values shown are means and standard error over the ﬁve simulations.
The performance of MARS is degraded only slightly by the inclusion of the
useless inputs in scenario 2; it performs substantially worse in scenario 3.

328

9. Additive Models, Trees, and Related Methods

TABLE 9.4. Proportional decrease in model error (R2) when MARS is applied
to three diﬀerent scenarios.

Scenario
1: Tensor product p = 2
2: Tensor product p = 20
3: Neural network

Mean (S.E.)
0.97 (0.01)
0.96 (0.01)
0.79 (0.01)

9.4.3 Other Issues

MARS for Classiﬁcation

The MARS method and algorithm can be extended to handle classiﬁcation
problems. Several strategies have been suggested.

For two classes, one can code the output as 0/1 and treat the problem as
a regression; we did this for the spam example. For more than two classes,
one can use the indicator response approach described in Section 4.2. One
codes the K response classes via 0/1 indicator variables, and then per-
forms a multi-response MARS regression. For the latter we use a common
set of basis functions for all response variables. Classiﬁcation is made to
the class with the largest predicted response value. There are, however, po-
tential masking problems with this approach, as described in Section 4.2.
A generally superior approach is the “optimal scoring” method discussed
in Section 12.5.

Stone et al. (1997) developed a hybrid of MARS called PolyMARS specif-
ically designed to handle classiﬁcation problems. It uses the multiple logistic
framework described in Section 4.4. It grows the model in a forward stage-
wise fashion like MARS, but at each stage uses a quadratic approximation
to the multinomial log-likelihood to search for the next basis-function pair.
Once found, the enlarged model is ﬁt by maximum likelihood, and the
process is repeated.

Relationship of MARS to CART

Although they might seem quite diﬀerent, the MARS and CART strategies
actually have strong similarities. Suppose we take the MARS procedure and
make the following changes:

•

•

Replace the piecewise linear basis functions by step functions I(x
0) and I(x

0).

t

−

≤

t >

−

When a model term is involved in a multiplication by a candidate
term, it gets replaced by the interaction, and hence is not available
for further interactions.

With these changes, the MARS forward procedure is the same as the CART
tree-growing algorithm. Multiplying a step function by a pair of reﬂected

9.5 Hierarchical Mixtures of Experts

329

step functions is equivalent to splitting a node at the step. The second
restriction implies that a node may not be split more than once, and leads
to the attractive binary-tree representation of the CART model. On the
other hand, it is this restriction that makes it diﬃcult for CART to model
additive structures. MARS forgoes the tree structure and gains the ability
to capture additive eﬀects.

Mixed Inputs

Mars can handle “mixed” predictors—quantitative and qualitative—in a
natural way, much like CART does. MARS considers all possible binary
partitions of the categories for a qualitative predictor into two groups.
Each such partition generates a pair of piecewise constant basis functions—
indicator functions for the two sets of categories. This basis pair is now
treated as any other, and is used in forming tensor products with other
basis functions already in the model.

9.5 Hierarchical Mixtures of Experts

The hierarchical mixtures of experts (HME) procedure can be viewed as a
variant of tree-based methods. The main diﬀerence is that the tree splits
are not hard decisions but rather soft probabilistic ones. At each node an
observation goes left or right with probabilities depending on its input val-
ues. This has some computational advantages since the resulting parameter
optimization problem is smooth, unlike the discrete split point search in the
tree-based approach. The soft splits might also help in prediction accuracy
and provide a useful alternative description of the data.

There are other diﬀerences between HMEs and the CART implementa-
tion of trees. In an HME, a linear (or logistic regression) model is ﬁt in
each terminal node, instead of a constant as in CART. The splits can be
multiway, not just binary, and the splits are probabilistic functions of a
linear combination of inputs, rather than a single input as in the standard
use of CART. However, the relative merits of these choices are not clear,
and most were discussed at the end of Section 9.2.

A simple two-level HME model in shown in Figure 9.13. It can be thought
of as a tree with soft splits at each non-terminal node. However, the inven-
tors of this methodology use a diﬀerent terminology. The terminal nodes
are called experts, and the non-terminal nodes are called gating networks.
The idea is that each expert provides an opinion (prediction) about the
response, and these are combined together by the gating networks. As we
will see, the model is formally a mixture model, and the two-level model
in the ﬁgure can be extend to multiple levels, hence the name hierarchical
mixtures of experts.

330

9. Additive Models, Trees, and Related Methods

Gating
Gating
Gating
Network
Network
Network

g1

g2

Gating
Gating
Gating
Network
Network
Network

Gating
Gating
Gating
Network
Network
Network

g1|1

g2|1

g1|2

g2|2

Expert
Expert
Expert
Network
Network
Network

Expert
Expert
Expert
Network
Network
Network

Expert
Expert
Network
Network

Expert
Expert
Expert
Network
Network
Network

Pr(y|x, θ11)

Pr(y|x, θ21)

Pr(y|x, θ12)

Pr(y|x, θ22)

FIGURE 9.13. A two-level hierarchical mixture of experts (HME) model.

Consider the regression or classiﬁcation problem, as described earlier in
the chapter. The data is (xi, yi), i = 1, 2, . . . , N , with yi either a continuous
or binary-valued response, and xi a vector-valued input. For ease of nota-
tion we assume that the ﬁrst element of xi is one, to account for intercepts.
Here is how an HME is deﬁned. The top gating network has the output

gj(x, γj) =

eγT
j x
K
k=1 eγT
k x

, j = 1, 2, . . . , K,

(9.25)

P

where each γj is a vector of unknown parameters. This represents a soft
K-way split (K = 2 in Figure 9.13.) Each gj(x, γj) is the probability of
assigning an observation with feature vector x to the jth branch. Notice
that with K = 2 groups, if we take the coeﬃcient of one of the elements of
x to be +
, then we get a logistic curve with inﬁnite slope. In this case,
the gating probabilities are either 0 or 1, corresponding to a hard split on
that input.

∞

At the second level, the gating networks have a similar form:

gℓ|j(x, γjℓ) =

eγT
jℓx
k=1 eγT
K
jkx

P

, ℓ = 1, 2, . . . , K.

(9.26)

9.5 Hierarchical Mixtures of Experts

331

This is the probability of assignment to the ℓth branch, given assignment
to the jth branch at the level above.

At each expert (terminal node), we have a model for the response variable

of the form

This diﬀers according to the problem.

Y

Pr(y

|

∼

x, θjℓ).

(9.27)

Regression: The Gaussian linear regression model is used, with θjℓ =

(βjℓ, σ2

jℓ):

Y = βT

jℓx + ε and ε

N (0, σ2

jℓ).

∼

Classiﬁcation: The linear logistic regression model is used:

Pr(Y = 1
|

x, θjℓ) =

1
1 + e−θT

jℓx

.

(9.28)

(9.29)

Denoting the collection of all parameters by Ψ =

probability that Y = y is

γj, γjℓ, θjℓ}
{

, the total

K

K

x, Ψ) =

gj(x, γj)

gℓ|j(x, γjℓ)Pr(y

Pr(y

|

x, θjℓ).

(9.30)

|

Xℓ=1
This is a mixture model, with the mixture probabilities determined by the
gating network models.

j=1
X

To estimate the parameters, we maximize the log-likelihood of the data,
xi, Ψ), over the parameters in Ψ. The most convenient method
i log Pr(yi|
for doing this is the EM algorithm, which we describe for mixtures in
P
Section 8.5. We deﬁne latent variables ∆j, all of which are zero except for
a single one. We interpret these as the branching decisions made by the top
level gating network. Similarly we deﬁne latent variables ∆ℓ|j to describe
the gating decisions at the second level.

In the E-step, the EM algorithm computes the expectations of the ∆j
and ∆ℓ|j given the current values of the parameters. These expectations
are then used as observation weights in the M-step of the procedure, to
estimate the parameters in the expert networks. The parameters in the
internal nodes are estimated by a version of multiple logistic regression.
The expectations of the ∆j or ∆ℓ|j are probability proﬁles, and these are
used as the response vectors for these logistic regressions.

The hierarchical mixtures of experts approach is a promising competitor
to CART trees. By using soft splits rather than hard decision rules it can
capture situations where the transition from low to high response is gradual.
The log-likelihood is a smooth function of the unknown weights and hence
is amenable to numerical optimization. The model is similar to CART with
linear combination splits, but the latter is more diﬃcult to optimize. On

332

9. Additive Models, Trees, and Related Methods

the other hand, to our knowledge there are no methods for ﬁnding a good
tree topology for the HME model, as there are in CART. Typically one uses
a ﬁxed tree of some depth, possibly the output of the CART procedure.
The emphasis in the research on HMEs has been on prediction rather than
interpretation of the ﬁnal model. A close cousin of the HME is the latent
class model (Lin et al., 2000), which typically has only one layer; here
the nodes or latent classes are interpreted as groups of subjects that show
similar response behavior.

9.6 Missing Data

It is quite common to have observations with missing values for one or more
input features. The usual approach is to impute (ﬁll-in) the missing values
in some way.

However, the ﬁrst issue in dealing with the problem is determining wheth-
er the missing data mechanism has distorted the observed data. Roughly
speaking, data are missing at random if the mechanism resulting in its
omission is independent of its (unobserved) value. A more precise deﬁnition
is given in Little and Rubin (2002). Suppose y is the response vector and X
p matrix of inputs (some of which are missing). Denote by Xobs
is the N
the observed entries in X and let Z = (y, X), Zobs = (y, Xobs). Finally, if R
is an indicator matrix with ijth entry 1 if xij is missing and zero otherwise,
then the data is said to be missing at random (MAR) if the distribution of
R depends on the data Z only through Zobs:

×

Pr(R

|

Z, θ) = Pr(R

Zobs, θ).

|

(9.31)

Here θ are any parameters in the distribution of R. Data are said to be
missing completely at random (MCAR) if the distribution of R doesn’t
depend on the observed or missing data:

Pr(R

|

Z, θ) = Pr(R

θ).

|

(9.32)

MCAR is a stronger assumption than MAR: most imputation methods rely
on MCAR for their validity.

For example, if a patient’s measurement was not taken because the doctor
felt he was too sick, that observation would not be MAR or MCAR. In this
case the missing data mechanism causes our observed training data to give a
distorted picture of the true population, and data imputation is dangerous
in this instance. Often the determination of whether features are MCAR
must be made from information about the data collection process. For
categorical features, one way to diagnose this problem is to code “missing”
as an additional class. Then we ﬁt our model to the training data and see
if class “missing” is predictive of the response.

9.6 Missing Data

333

Assuming the features are missing completely at random, there are a

number of ways of proceeding:

1. Discard observations with any missing values.

2. Rely on the learning algorithm to deal with missing values in its

training phase.

3. Impute all missing values before training.

Approach (1) can be used if the relative amount of missing data is small,
but otherwise should be avoided. Regarding (2), CART is one learning
algorithm that deals eﬀectively with missing values, through surrogate splits
(Section 9.2.4). MARS and PRIM use similar approaches. In generalized
additive modeling, all observations missing for a given input feature are
omitted when the partial residuals are smoothed against that feature in
the backﬁtting algorithm, and their ﬁtted values are set to zero. Since the
ﬁtted curves have mean zero (when the model includes an intercept), this
amounts to assigning the average ﬁtted value to the missing observations.
For most learning methods, the imputation approach (3) is necessary.
The simplest tactic is to impute the missing value with the mean or median
of the nonmissing values for that feature. (Note that the above procedure
for generalized additive models is analogous to this.)

If the features have at least some moderate degree of dependence, one
can do better by estimating a predictive model for each feature given the
other features and then imputing each missing value by its prediction from
the model. In choosing the learning method for imputation of the features,
one must remember that this choice is distinct from the method used for
predicting y from X. Thus a ﬂexible, adaptive method will often be pre-
ferred, even for the eventual purpose of carrying out a linear regression of y
on X. In addition, if there are many missing feature values in the training
set, the learning method must itself be able to deal with missing feature
values. CART therefore is an ideal choice for this imputation “engine.”

After imputation, missing values are typically treated as if they were ac-
tually observed. This ignores the uncertainty due to the imputation, which
will itself introduce additional uncertainty into estimates and predictions
from the response model. One can measure this additional uncertainty by
doing multiple imputations and hence creating many diﬀerent training sets.
The predictive model for y can be ﬁt to each training set, and the variation
across training sets can be assessed. If CART was used for the imputation
engine, the multiple imputations could be done by sampling from the values
in the corresponding terminal nodes.

334

9. Additive Models, Trees, and Related Methods

9.7 Computational Considerations

With N observations and p predictors, additive model ﬁtting requires some
number mp of applications of a one-dimensional smoother or regression
method. The required number of cycles m of the backﬁtting algorithm is
usually less than 20 and often less than 10, and depends on the amount
of correlation in the inputs. With cubic smoothing splines, for example,
N log N operations are needed for an initial sort and N operations for the
spline ﬁt. Hence the total operations for an additive model ﬁt is pN log N +
mpN .

Trees require pN log N operations for an initial sort for each predictor,
and typically another pN log N operations for the split computations. If the
splits occurred near the edges of the predictor ranges, this number could
increase to N 2p.

MARS requires N m2 + pmN operations to add a basis function to a
model with m terms already present, from a pool of p predictors. Hence to
build an M -term model requires N M 3 + pM 2N computations, which can
be quite prohibitive if M is a reasonable fraction of N .

Each of the components of an HME are typically inexpensive to ﬁt at
each M-step: N p2 for the regressions, and N p2K 2 for a K-class logistic
regression. The EM algorithm, however, can take a long time to converge,
and so sizable HME models are considered costly to ﬁt.

Bibliographic Notes

The most comprehensive source for generalized additive models is the text
of that name by Hastie and Tibshirani (1990). Diﬀerent applications of
this work in medical problems are discussed in Hastie et al. (1989) and
Hastie and Herman (1990), and the software implementation in Splus is
described in Chambers and Hastie (1991). Green and Silverman (1994)
discuss penalization and spline models in a variety of settings. Efron and
Tibshirani (1991) give an exposition of modern developments in statistics
(including generalized additive models), for a nonmathematical audience.
Classiﬁcation and regression trees date back at least as far as Morgan and
Sonquist (1963). We have followed the modern approaches of Breiman et
al. (1984) and Quinlan (1993). The PRIM method is due to Friedman
and Fisher (1999), while MARS is introduced in Friedman (1991), with an
additive precursor in Friedman and Silverman (1989). Hierarchical mixtures
of experts were proposed in Jordan and Jacobs (1994); see also Jacobs et
al. (1991).

Exercises

335

Exercises

Ex. 9.1 Show that a smoothing spline ﬁt of yi to xi preserves the linear
part of the ﬁt. In other words, if yi = ˆyi + ri, where ˆyi represents the
linear regression ﬁts, and S is the smoothing matrix, then Sy = ˆy + Sr.
Show that the same is true for local linear regression (Section 6.1.1). Hence
argue that the adjustment step in the second line of (2) in Algorithm 9.1
is unnecessary.

×

k matrix, b be a known k-vector, and z
Ex. 9.2 Let A be a known k
be an unknown k-vector. A Gauss–Seidel algorithm for solving the linear
system of equations Az = b works by successively solving for element zj in
the jth equation, ﬁxing all other zj’s at their current guesses. This process
is repeated for j = 1, 2, . . . , k, 1, 2, . . . , k, . . . , until convergence (Golub and
Van Loan, 1983).

(a) Consider an additive model with N observations and p terms, with
the jth term to be ﬁt by a linear smoother Sj. Consider the following
system of equations:









.

(9.33)



S1 S1
I
S2
I
S2
...
...
...
Sp Sp Sp

· · ·
· · ·
. . .

S1
S2
...
I

f1
f2
...
fp

S1y
S2y
...
Spy

= 














Here each fj is an N -vector of evaluations of the jth function at
the data points, and y is an N -vector of the response values. Show
that backﬁtting is a blockwise Gauss–Seidel algorithm for solving this
system of equations.
















· · ·

(b) Let S1 and S2 be symmetric smoothing operators (matrices) with
eigenvalues in [0, 1). Consider a backﬁtting algorithm with response
vector y and smoothers S1, S2. Show that with any starting values,
the algorithm converges and give a formula for the ﬁnal iterates.

Ex. 9.3 Backﬁtting equations. Consider a backﬁtting procedure with orthog-
onal projections, and let D be the overall regression matrix whose columns
Lcol(S) denotes the
span V =
column space of a matrix S. Show that the estimating equations

⊕ · · · ⊕ Lcol(Sp), where

⊕ Lcol(S2)

Lcol(S1)

I
S1 S1
S2
I
S2
...
...
...
Sp Sp Sp

S1
S2
...
I

· · ·
· · ·
. . .

· · ·








f1
f2
...
fp






















= 





S1y
S2y
...
Spy








are equivalent to the least squares normal equations DT Dβ = DT y where
β is the vector of coeﬃcients.

336

9. Additive Models, Trees, and Related Methods

Ex. 9.4 Suppose the same smoother S is used to estimate both terms in a
two-term additive model (i.e., both variables are identical). Assume that S
is symmetric with eigenvalues in [0, 1). Show that the backﬁtting residual
converges to (I + S)−1(I
S)y, and that the residual sum of squares con-
verges upward. Can the residual sum of squares converge upward in less
structured situations? How does this ﬁt compare to the ﬁt with a single
term ﬁt by S? [Hint: Use the eigen-decomposition of S to help with this
comparison.]

−

Ex. 9.5 Degrees of freedom of a tree. Given data yi with mean f (xi) and
variance σ2, and a ﬁtting operation y
ˆy, let’s deﬁne the degrees of
freedom of a ﬁt by

i cov(yi, ˆyi)/σ2.

Consider a ﬁt ˆy estimated by a regression tree, ﬁt to a set of predictors

→

X1, X2, . . . , Xp.

P

(a) In terms of the number of terminal nodes m, give a rough formula for

the degrees of freedom of the ﬁt.

(b) Generate 100 observations with predictors X1, X2, . . . , X10 as inde-

pendent standard Gaussian variates and ﬁx these values.

(c) Generate response values also as standard Gaussian (σ2 = 1), indepen-
dent of the predictors. Fit regression trees to the data of ﬁxed size 1,5
and 10 terminal nodes and hence estimate the degrees of freedom of
each ﬁt. [Do ten simulations of the response and average the results,
to get a good estimate of degrees of freedom.]

(d) Compare your estimates of degrees of freedom in (a) and (c) and

discuss.

(e) If the regression tree ﬁt were a linear operation, we could write ˆy = Sy
for some matrix S. Then the degrees of freedom would be tr(S).
Suggest a way to compute an approximate S matrix for a regression
tree, compute it and compare the resulting degrees of freedom to
those in (a) and (c).

Ex. 9.6 Consider the ozone data of Figure 6.9.

(a) Fit an additive model to the cube root of ozone concentration. as a
function of temperature, wind speed, and radiation. Compare your
results to those obtained via the trellis display in Figure 6.9.

(b) Fit trees, MARS, and PRIM to the same data, and compare the results

to those found in (a) and in Figure 6.9.

10
Boosting and Additive Trees

This is page 337
Printer: Opaque this

10.1 Boosting Methods

Boosting is one of the most powerful learning ideas introduced in the last
twenty years. It was originally designed for classiﬁcation problems, but as
will be seen in this chapter, it can proﬁtably be extended to regression
as well. The motivation for boosting was a procedure that combines the
outputs of many “weak” classiﬁers to produce a powerful “committee.”
From this perspective boosting bears a resemblance to bagging and other
committee-based approaches (Section 8.8). However we shall see that the
connection is at best superﬁcial and that boosting is fundamentally diﬀer-
ent.

We begin by describing the most popular boosting algorithm due to
Freund and Schapire (1997) called “AdaBoost.M1.” Consider a two-class
problem, with the output variable coded as Y
. Given a vector of
1, 1
}
predictor variables X, a classiﬁer G(X) produces a prediction taking one
of the two values

. The error rate on the training sample is
1, 1
}

∈ {−

{−

err =

1
N

N

i=1
X

I(yi 6

= G(xi)),

and the expected error rate on future predictions is EXY I(Y

= G(X)).

A weak classiﬁer is one whose error rate is only slightly better than
random guessing. The purpose of boosting is to sequentially apply the
weak classiﬁcation algorithm to repeatedly modiﬁed versions of the data,
thereby producing a sequence of weak classiﬁers Gm(x), m = 1, 2, . . . , M .

6
338

10. Boosting and Additive Trees

Final Classifier

G(x) = sign

M
m=1 αmGm(x)

hP

GM (x)

i

Weighted  Sample
Weighted  Sample
Weighted  Sample
Weighted  Sample
Weighted  Sample

Weighted  Sample
Weighted  Sample
Weighted  Sample
Weighted  Sample
Weighted  Sample

G3(x)

Weighted  Sample
Weighted  Sample
Weighted  Sample
Weighted  Sample
Weighted  Sample

G2(x)

Training  Sample
Training  Sample
Training  Sample
Training  Sample
Training  Sample

G1(x)

FIGURE 10.1. Schematic of AdaBoost. Classiﬁers are trained on weighted ver-
sions of the dataset, and then combined to produce a ﬁnal prediction.

The predictions from all of them are then combined through a weighted
majority vote to produce the ﬁnal prediction:

M

G(x) = sign

αmGm(x)

.

(10.1)

!

m=1
X
Here α1, α2, . . . , αM are computed by the boosting algorithm, and weight
the contribution of each respective Gm(x). Their eﬀect is to give higher
inﬂuence to the more accurate classiﬁers in the sequence. Figure 10.1 shows
a schematic of the AdaBoost procedure.

The data modiﬁcations at each boosting step consist of applying weights
w1, w2, . . . , wN to each of the training observations (xi, yi), i = 1, 2, . . . , N .
Initially all of the weights are set to wi = 1/N , so that the ﬁrst step simply
trains the classiﬁer on the data in the usual manner. For each successive
iteration m = 2, 3, . . . , M the observation weights are individually modi-
ﬁed and the classiﬁcation algorithm is reapplied to the weighted observa-
tions. At step m, those observations that were misclassiﬁed by the classiﬁer
Gm−1(x) induced at the previous step have their weights increased, whereas
the weights are decreased for those that were classiﬁed correctly. Thus as
iterations proceed, observations that are diﬃcult to classify correctly re-
ceive ever-increasing inﬂuence. Each successive classiﬁer is thereby forced

 
10.1 Boosting Methods

339

Algorithm 10.1 AdaBoost.M1.

1. Initialize the observation weights wi = 1/N, i = 1, 2, . . . , N .

2. For m = 1 to M :

(a) Fit a classiﬁer Gm(x) to the training data using weights wi.
(b) Compute

errm =

P

N

i=1 wiI(yi 6

= Gm(xi))

.

N
i=1 wi

(c) Compute αm = log((1
exp[αm ·
wi ·
(d) Set wi ←
3. Output G(x) = sign

errm)/errm).
P
−
I(yi 6
M
m=1 αmGm(x)

.

= Gm(xi))], i = 1, 2, . . . , N .

hP

i

to concentrate on those training observations that are missed by previous
ones in the sequence.

Algorithm 10.1 shows the details of the AdaBoost.M1 algorithm. The
current classiﬁer Gm(x) is induced on the weighted observations at line 2a.
The resulting weighted error rate is computed at line 2b. Line 2c calculates
the weight αm given to Gm(x) in producing the ﬁnal classiﬁer G(x) (line
3). The individual weights of each of the observations are updated for the
next iteration at line 2d. Observations misclassiﬁed by Gm(x) have their
weights scaled by a factor exp(αm), increasing their relative inﬂuence for
inducing the next classiﬁer Gm+1(x) in the sequence.

The AdaBoost.M1 algorithm is known as “Discrete AdaBoost” in Fried-
man et al. (2000), because the base classiﬁer Gm(x) returns a discrete class
label. If the base classiﬁer instead returns a real-valued prediction (e.g.,
1, 1]), AdaBoost can be modiﬁed
a probability mapped to the interval [
appropriately (see “Real AdaBoost” in Friedman et al. (2000)).

−

The power of AdaBoost to dramatically increase the performance of even
a very weak classiﬁer is illustrated in Figure 10.2. The features X1, . . . , X10
are standard independent Gaussian, and the deterministic target Y is de-
ﬁned by

1

Y =

1

(cid:26)

−

10
j=1 X 2
if
otherwise.

P

j > χ2

10(0.5),

(10.2)

Here χ2
10(0.5) = 9.34 is the median of a chi-squared random variable with
10 degrees of freedom (sum of squares of 10 standard Gaussians). There are
2000 training cases, with approximately 1000 cases in each class, and 10,000
test observations. Here the weak classiﬁer is just a “stump”: a two terminal-
node classiﬁcation tree. Applying this classiﬁer alone to the training data
set yields a very poor test set error rate of 45.8%, compared to 50% for

340

10. Boosting and Additive Trees

Single Stump

244 Node Tree

r
o
r
r

E

t
s
e
T

5

.

0

4

.

0

3
0

.

2

.

0

1
.
0

0
.
0

0

100

200

300

400

Boosting Iterations

FIGURE 10.2. Simulated data (10.2): test error rate for boosting with stumps,
as a function of the number of iterations. Also shown are the test error rate for
a single stump, and a 244-node classiﬁcation tree.

random guessing. However, as boosting iterations proceed the error rate
steadily decreases, reaching 5.8% after 400 iterations. Thus, boosting this
simple very weak classiﬁer reduces its prediction error rate by almost a
factor of four. It also outperforms a single large classiﬁcation tree (error
rate 24.7%). Since its introduction, much has been written to explain the
success of AdaBoost in producing accurate classiﬁers. Most of this work
has centered on using classiﬁcation trees as the “base learner” G(x), where
improvements are often most dramatic. In fact, Breiman (NIPS Workshop,
1996) referred to AdaBoost with trees as the “best oﬀ-the-shelf classiﬁer in
the world” (see also Breiman (1998)). This is especially the case for data-
mining applications, as discussed more fully in Section 10.7 later in this
chapter.

10.1.1 Outline of This Chapter

Here is an outline of the developments in this chapter:

•

We show that AdaBoost ﬁts an additive model in a base learner,
optimizing a novel exponential loss function. This loss function is

 
10.2 Boosting Fits an Additive Model

341

very similar to the (negative) binomial log-likelihood (Sections 10.2–
10.4).

The population minimizer of the exponential loss function is shown
to be the log-odds of the class probabilities (Section 10.5).

We describe loss functions for regression and classiﬁcation that are
more robust than squared error or exponential loss (Section 10.6).

It is argued that decision trees are an ideal base learner for data
mining applications of boosting (Sections 10.7 and 10.9).

We develop a class of gradient boosted models (GBMs), for boosting
trees with any loss function (Section 10.10).

The importance of “slow learning” is emphasized, and implemented
by shrinkage of each new term that enters the model (Section 10.12),
as well as randomization (Section 10.12.2).

Tools for interpretation of the ﬁtted model are described (Section 10.13).

•

•

•

•

•

•

10.2 Boosting Fits an Additive Model

The success of boosting is really not very mysterious. The key lies in ex-
pression (10.1). Boosting is a way of ﬁtting an additive expansion in a set
of elementary “basis” functions. Here the basis functions are the individual
classiﬁers Gm(x)
. More generally, basis function expansions take
1, 1
}
the form

∈ {−

M

f (x) =

βmb(x; γm),

(10.3)

m=1
X
where βm, m = 1, 2, . . . , M are the expansion coeﬃcients, and b(x; γ)
IR
are usually simple functions of the multivariate argument x, characterized
by a set of parameters γ. We discuss basis expansions in some detail in
Chapter 5.

∈

Additive expansions like this are at the heart of many of the learning

techniques covered in this book:

•

•

•

In single-hidden-layer neural networks (Chapter 11), b(x; γ) = σ(γ0 +
γT
1 x), where σ(t) = 1/(1 + e−t) is the sigmoid function, and γ param-
eterizes a linear combination of the input variables.

In signal processing, wavelets (Section 5.9.1) are a popular choice with
γ parameterizing the location and scale shifts of a “mother” wavelet.

Multivariate adaptive regression splines (Section 9.4) uses truncated-
power spline basis functions where γ parameterizes the variables and
values for the knots.

342

10. Boosting and Additive Trees

Algorithm 10.2 Forward Stagewise Additive Modeling.

1. Initialize f0(x) = 0.

2. For m = 1 to M :

(a) Compute

(βm, γm) = arg min
β,γ

N

i=1
X

L(yi, fm−1(xi) + βb(xi; γ)).

(b) Set fm(x) = fm−1(x) + βmb(x; γm).

•

For trees, γ parameterizes the split variables and split points at the
internal nodes, and the predictions at the terminal nodes.

Typically these models are ﬁt by minimizing a loss function averaged
over the training data, such as the squared-error or a likelihood-based loss
function,

min
{βm,γm}M
1

N

M

L

yi,

βmb(xi; γm)

i=1
X

m=1
X

.

!

(10.4)

For many loss functions L(y, f (x)) and/or basis functions b(x; γ), this re-
quires computationally intensive numerical optimization techniques. How-
ever, a simple alternative often can be found when it is feasible to rapidly
solve the subproblem of ﬁtting just a single basis function,

min
β,γ

N

i=1
X

L (yi, βb(xi; γ)) .

(10.5)

10.3 Forward Stagewise Additive Modeling

Forward stagewise modeling approximates the solution to (10.4) by sequen-
tially adding new basis functions to the expansion without adjusting the
parameters and coeﬃcients of those that have already been added. This is
outlined in Algorithm 10.2. At each iteration m, one solves for the optimal
basis function b(x; γm) and corresponding coeﬃcient βm to add to the cur-
rent expansion fm−1(x). This produces fm(x), and the process is repeated.
Previously added terms are not modiﬁed.

For squared-error loss

L(y, f (x)) = (y

f (x))2,

−

(10.6)

 
10.4 Exponential Loss and AdaBoost

343

one has

L(yi, fm−1(xi) + βb(xi; γ)) = (yi −
= (rim −

fm−1(xi)

−
βb(xi; γ))2,

βb(xi; γ))2

(10.7)

fm−1(xi) is simply the residual of the current model
where rim = yi −
on the ith observation. Thus, for squared-error loss, the term βmb(x; γm)
that best ﬁts the current residuals is added to the expansion at each step.
This idea is the basis for “least squares” regression boosting discussed in
Section 10.10.2. However, as we show near the end of the next section,
squared-error loss is generally not a good choice for classiﬁcation; hence
the need to consider other loss criteria.

10.4 Exponential Loss and AdaBoost

We now show that AdaBoost.M1 (Algorithm 10.1) is equivalent to forward
stagewise additive modeling (Algorithm 10.2) using the loss function

L(y, f (x)) = exp(

y f (x)).

−

(10.8)

The appropriateness of this criterion is addressed in the next section.

For AdaBoost the basis functions are the individual classiﬁers Gm(x)
. Using the exponential loss function, one must solve
1, 1
}

{−

∈

(βm, Gm) = arg min
β,G

N

i=1
X

exp[

−

yi(fm−1(xi) + β G(xi))]

for the classiﬁer Gm and corresponding coeﬃcient βm to be added at each
step. This can be expressed as

(βm, Gm) = arg min
β,G

N

w(m)
i

exp(

−

β yi G(xi))

(10.9)

i=1
X
with w(m)
yi fm−1(xi)). Since each w(m)
depends neither on β
nor G(x), it can be regarded as a weight that is applied to each observa-
tion. This weight depends on fm−1(xi), and so the individual weight values
change with each iteration m.

= exp(

−

i

i

The solution to (10.9) can be obtained in two steps. First, for any value

of β > 0, the solution to (10.9) for Gm(x) is

Gm = arg min
G

N

i=1
X

w(m)
i

I(yi 6

= G(xi)),

(10.10)

344

10. Boosting and Additive Trees

which is the classiﬁer that minimizes the weighted error rate in predicting
y. This can be easily seen by expressing the criterion in (10.9) as

e−β

·

w(m)

i + eβ

w(m)
i

,

·

Xyi6=G(xi)

Xyi=G(xi)
which in turn can be written as

eβ

−

e−β

(cid:0)

N

·

(cid:1)

i=1
X

w(m)
i

I(yi 6

= G(xi)) + e−β

w(m)
i

.

N

·

i=1
X

Plugging this Gm into (10.9) and solving for β one obtains

βm =

1
2

log

1

errm

−
errm

,

where errm is the minimized weighted error rate

(10.11)

(10.12)

errm =

P

N

i=1 w(m)

i

= Gm(xi))

I(yi 6
i=1 w(m)

N

i

The approximation is then updated

P

fm(x) = fm−1(x) + βmGm(x),

which causes the weights for the next iteration to be

.

(10.13)

(10.14)

w(m+1)

i

= w(m)
i

e−βmyiGm(xi).

·
I(yi 6

·

Using the fact that

yiGm(xi) = 2

= Gm(xi))

1, (10.14) becomes

−
w(m+1)

i

= w(m)
i

·

eαmI(yi6=Gm(xi))

·

−
e−βm ,

(10.15)

where αm = 2βm is the quantity deﬁned at line 2c of AdaBoost.M1 (Al-
gorithm 10.1). The factor e−βm in (10.15) multiplies all weights by the
same value, so it has no eﬀect. Thus (10.15) is equivalent to line 2(d) of
Algorithm 10.1.

One can view line 2(a) of the Adaboost.M1 algorithm as a method for
approximately solving the minimization in (10.11) and hence (10.10). Hence
we conclude that AdaBoost.M1 minimizes the exponential loss criterion
(10.8) via a forward-stagewise additive modeling approach.

Figure 10.3 shows the training-set misclassiﬁcation error rate and aver-
age exponential loss for the simulated data problem (10.2) of Figure 10.2.
The training-set misclassiﬁcation error decreases to zero at around 250 it-
erations (and remains there), but the exponential loss keeps decreasing.
Notice also in Figure 10.2 that the test-set misclassiﬁcation error continues
to improve after iteration 250. Clearly Adaboost is not optimizing training-
set misclassiﬁcation error; the exponential loss is more sensitive to changes
in the estimated class probabilities.

10.5 Why Exponential Loss?

345

0

.

1

8
0

.

6

.

0

r
o
r
r

i

E
g
n
n
a
r
T

i

4
0

.

2
.
0

0
.
0

Exponential Loss

Misclassification Rate

0

100

200

300

400

Boosting Iterations

FIGURE 10.3. Simulated data, boosting with stumps: misclassiﬁcation error
yif (xi)).
rate on the training set, and average exponential loss: (1/N )
After about 250 iterations, the misclassiﬁcation error is zero, while the exponential
loss continues to decrease.

N
i=1 exp(

P

−

10.5 Why Exponential Loss?

The AdaBoost.M1 algorithm was originally motivated from a very diﬀer-
ent perspective than presented in the previous section. Its equivalence to
forward stagewise additive modeling based on exponential loss was only
discovered ﬁve years after its inception. By studying the properties of the
exponential loss criterion, one can gain insight into the procedure and dis-
cover ways it might be improved.

The principal attraction of exponential loss in the context of additive
modeling is computational; it leads to the simple modular reweighting Ad-
aBoost algorithm. However, it is of interest to inquire about its statistical
properties. What does it estimate and how well is it being estimated? The
ﬁrst question is answered by seeking its population minimizer.

It is easy to show (Friedman et al., 2000) that

f ∗(x) = arg min
f (x)

EY |x(e−Y f (x)) =

1
2

log

x)
Pr(Y = 1
|
x)
1
Pr(Y =
|

−

,

(10.16)

 
346

10. Boosting and Additive Trees

or equivalently

Pr(Y = 1
|

x) =

1
1 + e−2f ∗(x) .

Thus, the additive expansion produced by AdaBoost is estimating one-
x). This justiﬁes using its sign as the classiﬁ-

half the log-odds of P (Y = 1
|
cation rule in (10.1).

Another loss criterion with the same population minimizer is the bi-
nomial negative log-likelihood or deviance (also known as cross-entropy),
interpreting f as the logit transform. Let

p(x) = Pr(Y = 1

x) =

|

ef (x)
e−f (x) + ef (x) =

1
1 + e−2f (x)

(10.17)

and deﬁne Y ′ = (Y + 1)/2
function is

. Then the binomial log-likelihood loss
0, 1
}

∈ {

l(Y, p(x)) = Y ′ log p(x) + (1

Y ′) log(1

p(x)),

−

−

or equivalently the deviance is

l(Y, f (x)) = log

1 + e−2Y f (x)

.

(10.18)

−

(cid:16)

(cid:17)

Since the population maximizer of log-likelihood is at the true probabilities
x), we see from (10.17) that the population minimizers of
p(x) = Pr(Y = 1
|
l(Y, f (x))] and EY |x[e−Y f (x)] are the same. Thus, using
the deviance EY |x[
either criterion leads to the same solution at the population level. Note that
e−Y f itself is not a proper log-likelihood, since it is not the logarithm of
any probability mass function for a binary random variable Y

−

∈ {−

.
1, 1
}

10.6 Loss Functions and Robustness

In this section we examine the diﬀerent loss functions for classiﬁcation and
regression more closely, and characterize them in terms of their robustness
to extreme data.

Robust Loss Functions for Classiﬁcation

Although both the exponential (10.8) and binomial deviance (10.18) yield
the same solution when applied to the population joint distribution, the
same is not true for ﬁnite data sets. Both criteria are monotone decreasing
1/1 response)
functions of the “margin” yf (x). In classiﬁcation (with a
the margin plays a role analogous to the residuals y
f (x) in regression. The
classiﬁcation rule G(x) = sign[f (x)] implies that observations with positive
margin yif (xi) > 0 are classiﬁed correctly whereas those with negative
margin yif (xi) < 0 are misclassiﬁed. The decision boundary is deﬁned by

−

−

10.6 Loss Functions and Robustness

347

Misclassification
Exponential
Binomial Deviance
Squared Error
Support Vector

s
s
o
L

0

.

3

5

.

2

0
2

.

5
1

.

0

.

1

5

.

0

0
.
0

−2

−1

1

2

0

y

f

·

±

FIGURE 10.4. Loss functions for two-class classiﬁcation. The response is
1; the prediction is f , with class prediction sign(f ). The losses are
y =
misclassiﬁcation: I(sign(f )
yf ); binomial deviance:
yf )+ (see
log(1 + exp(
−
Section 12.3). Each function has been scaled so that it passes through the point
(0, 1).

−
f )2; and support vector: (1

= y); exponential: exp(

2yf )); squared error: (y

−

−

f (x) = 0. The goal of the classiﬁcation algorithm is to produce positive
margins as frequently as possible. Any loss criterion used for classiﬁcation
should penalize negative margins more heavily than positive ones since
positive margin observations are already correctly classiﬁed.

·

·

Figure 10.4 shows both the exponential (10.8) and binomial deviance
f (x). Also shown is misclassiﬁcation
criteria as a function of the margin y
loss L(y, f (x)) = I(y
f (x) < 0), which gives unit penalty for negative mar-
gin values, and no penalty at all for positive ones. Both the exponential
and deviance loss can be viewed as monotone continuous approximations
to misclassiﬁcation loss. They continuously penalize increasingly negative
margin values more heavily than they reward increasingly positive ones.
The diﬀerence between them is in degree. The penalty associated with bi-
nomial deviance increases linearly for large increasingly negative margin,
whereas the exponential criterion increases the inﬂuence of such observa-
tions exponentially.

At any point in the training process the exponential criterion concen-
trates much more inﬂuence on observations with large negative margins.
Binomial deviance concentrates relatively less inﬂuence on such observa-

6
348

10. Boosting and Additive Trees

tions, more evenly spreading the inﬂuence among all of the data. It is
therefore far more robust in noisy settings where the Bayes error rate is
not close to zero, and especially in situations where there is misspeciﬁcation
of the class labels in the training data. The performance of AdaBoost has
been empirically observed to dramatically degrade in such situations.

Also shown in the ﬁgure is squared-error loss. The minimizer of the cor-

responding risk on the population is

f ∗(x) = arg min
f (x)

EY |x(Y

−

f (x))2 = E(Y

x) = 2

·

|

Pr(Y = 1

x)

|

−

1. (10.19)

As before the classiﬁcation rule is G(x) = sign[f (x)]. Squared-error loss
is not a good surrogate for misclassiﬁcation error. As seen in Figure 10.4, it
is not a monotone decreasing function of increasing margin yf (x). For mar-
gin values yif (xi) > 1 it increases quadratically, thereby placing increasing
inﬂuence (error) on observations that are correctly classiﬁed with increas-
ing certainty, thereby reducing the relative inﬂuence of those incorrectly
classiﬁed yif (xi) < 0. Thus, if class assignment is the goal, a monotone de-
creasing criterion serves as a better surrogate loss function. Figure 12.4 on
page 426 in Chapter 12 includes a modiﬁcation of quadratic loss, the “Hu-
berized” square hinge loss (Rosset et al., 2004b), which enjoys the favorable
properties of the binomial deviance, quadratic loss and the SVM hinge loss.
It has the same population minimizer as the quadratic (10.19), is zero for
1. Since quadratic functions
y
·
are easier to compute with than exponentials, our experience suggests this
to be a useful alternative to the binomial deviance.

f (x) > 1, and becomes linear for y

f (x) <

−

·

G

=

With K-class classiﬁcation, the response Y takes values in the unordered
(see Sections 2.4 and 4.4). We now seek a classiﬁer
. It is suﬃcient to know the class conditional proba-
x), k = 1, 2, . . . , K, for then the Bayes classiﬁer
Gk|

set
{G1, . . . ,
Gk}
G(x) taking values in
G
bilities pk(x) = Pr(Y =
is

G(x) =

Gk where k = arg max
In principal, though, we need not learn the pk(x), but simply which one is
largest. However, in data mining applications the interest is often more in
the class probabilities pℓ(x), ℓ = 1, . . . , K themselves, rather than in per-
forming a class assignment. As in Section 4.4, the logistic model generalizes
naturally to K classes,

(10.20)

pℓ(x).

ℓ

pk(x) =

efk(x)
K
l=1 efl(x)

,

(10.21)

P
which ensures that 0
1 and that they sum to one. Note that
here we have K diﬀerent functions, one per class. There is a redundancy
in the functions fk(x), since adding an arbitrary h(x) to each leaves the
model unchanged. Traditionally one of them is set to zero: for example,

pk(x)

≤

≤

10.6 Loss Functions and Robustness

349

fK (x) = 0, as in (4.17). Here we prefer to retain the symmetry, and impose
K
the constraint
k=1 fk(x) = 0. The binomial deviance extends naturally
to the K-class multinomial deviance loss function:

P

L(y, p(x)) =

=

K

−

−

Xk=1
K

Xk=1

I(y =

Gk) log pk(x)

I(y =

Gk)fk(x) + log

K

Xℓ=1

efℓ(x)

!

. (10.22)

As in the two-class case, the criterion (10.22) penalizes incorrect predictions
only linearly in their degree of incorrectness.

Zhu et al. (2005) generalize the exponential loss for K-class problems.

See Exercise 10.5 for details.

Robust Loss Functions for Regression

|

|

|

|

y

−

−

f (x)

f (x))2 and absolute loss L(y, f (x)) =

In the regression setting, analogous to the relationship between exponential
loss and binomial log-likelihood is the relationship between squared-error
loss L(y, f (x)) = (y
. The
population solutions are f (x) = E(Y
x) for squared-error loss, and f (x) =
median(Y
x) for absolute loss; for symmetric error distributions these are
the same. However, on ﬁnite samples squared-error loss places much more
emphasis on observations with large absolute residuals
during
the ﬁtting process. It is thus far less robust, and its performance severely
degrades for long-tailed error distributions and especially for grossly mis-
measured y-values (“outliers”). Other more robust criteria, such as abso-
lute loss, perform much better in these situations. In the statistical ro-
bustness literature, a variety of regression loss criteria have been proposed
that provide strong resistance (if not absolute immunity) to gross outliers
while being nearly as eﬃcient as least squares for Gaussian errors. They
are often better than either for error distributions with moderately heavy
tails. One such criterion is the Huber loss criterion used for M-regression
(Huber, 1964)

yi −

f (xi)

|

|

L(y, f (x)) =

f (x)]2
f (x)

[y
y

−
−

2δ

δ2

|
Figure 10.5 compares these three loss functions.

| −

(cid:26)

y
for
otherwise.

−

|

f (x)

δ,

| ≤

(10.23)

These considerations suggest that when robustness is a concern, as is
especially the case in data mining applications (see Section 10.7), squared-
error loss for regression and exponential loss for classiﬁcation are not the
best criteria from a statistical perspective. However, they both lead to the
elegant modular boosting algorithms in the context of forward stagewise
additive modeling. For squared-error loss one simply ﬁts the base learner
fm−1(xi) at each step. For
to the residuals from the current model yi −

 
350

10. Boosting and Additive Trees

Squared Error
Absolute Error
Huber

s
s
o
L

8

6

4

2

0

−3

−2

−1

1

2

3

0

−

f

y

FIGURE 10.5. A comparison of three loss functions for regression, plotted as a
function of the margin y
f . The Huber loss function combines the good properties
of squared-error loss near zero and absolute error loss when

is large.

−

y

f

|

−

|

exponential loss one performs a weighted ﬁt of the base learner to the
yifm−1(xi)). Using other more
output values yi, with weights wi = exp(
robust criteria directly in their place does not give rise to such simple
feasible boosting algorithms. However, in Section 10.10.2 we show how one
can derive simple elegant boosting algorithms based on any diﬀerentiable
loss criterion, thereby producing highly robust boosting procedures for data
mining.

−

10.7

“Oﬀ-the-Shelf” Procedures for Data Mining

Predictive learning is an important aspect of data mining. As can be seen
from this book, a wide variety of methods have been developed for predic-
tive learning from data. For each particular method there are situations
for which it is particularly well suited, and others where it performs badly
compared to the best that can be done with that data. We have attempted
to characterize appropriate situations in our discussions of each of the re-
spective methods. However, it is seldom known in advance which procedure
will perform best or even well for any given problem. Table 10.1 summarizes
some of the characteristics of a number of learning methods.

Industrial and commercial data mining applications tend to be especially
challenging in terms of the requirements placed on learning procedures.
Data sets are often very large in terms of number of observations and
number of variables measured on each of them. Thus, computational con-

10.7 “Oﬀ-the-Shelf” Procedures for Data Mining

351

TABLE 10.1. Some characteristics of diﬀerent learning methods. Key: s = good,
u=fair, and t =poor.

Characteristic

Neural

SVM Trees MARS

k-NN,

Nets

Kernels

Natural handling of data
of “mixed” type

Handling of missing values

Robustness to outliers in
input space

Insensitive to monotone
transformations of inputs

Computational scalability
(large N )

Ability to deal with irrel-
evant inputs

Ability to extract linear
combinations of features

Interpretability

Predictive power

u

u

u

siderations play an important role. Also, the data are usually messy: the
inputs tend to be mixtures of quantitative, binary, and categorical vari-
ables, the latter often with many levels. There are generally many missing
values, complete observations being rare. Distributions of numeric predic-
tor and response variables are often long-tailed and highly skewed. This
is the case for the spam data (Section 9.1.2); when ﬁtting a generalized
additive model, we ﬁrst log-transformed each of the predictors in order to
get a reasonable ﬁt. In addition they usually contain a substantial fraction
of gross mis-measurements (outliers). The predictor variables are generally
measured on very diﬀerent scales.

In data mining applications, usually only a small fraction of the large
number of predictor variables that have been included in the analysis are
actually relevant to prediction. Also, unlike many applications such as pat-
tern recognition, there is seldom reliable domain knowledge to help create
especially relevant features and/or ﬁlter out the irrelevant ones, the inclu-
sion of which dramatically degrades the performance of many methods.

In addition, data mining applications generally require interpretable mod-
els. It is not enough to simply produce predictions. It is also desirable to
have information providing qualitative understanding of the relationship

t
t
s
s
t
t
t
s
s
s
t
t
s
t
s
t
t
s
t
t
t
t
s
s
t
t
t
s
s
t
s
s
t
t
t
t
s
t
s
s
t
s
352

10. Boosting and Additive Trees

between joint values of the input variables and the resulting predicted re-
sponse value. Thus, black box methods such as neural networks, which can
be quite useful in purely predictive settings such as pattern recognition,
are far less useful for data mining.

These requirements of speed, interpretability and the messy nature of
the data sharply limit the usefulness of most learning procedures as oﬀ-
the-shelf methods for data mining. An “oﬀ-the-shelf” method is one that
can be directly applied to the data without requiring a great deal of time-
consuming data preprocessing or careful tuning of the learning procedure.
Of all the well-known learning methods, decision trees come closest to
meeting the requirements for serving as an oﬀ-the-shelf procedure for data
mining. They are relatively fast to construct and they produce interpretable
models (if the trees are small). As discussed in Section 9.2, they naturally
incorporate mixtures of numeric and categorical predictor variables and
missing values. They are invariant under (strictly monotone) transforma-
tions of the individual predictors. As a result, scaling and/or more general
transformations are not an issue, and they are immune to the eﬀects of pre-
dictor outliers. They perform internal feature selection as an integral part
of the procedure. They are thereby resistant, if not completely immune,
to the inclusion of many irrelevant predictor variables. These properties of
decision trees are largely the reason that they have emerged as the most
popular learning method for data mining.

Trees have one aspect that prevents them from being the ideal tool for
predictive learning, namely inaccuracy. They seldom provide predictive ac-
curacy comparable to the best that can be achieved with the data at hand.
As seen in Section 10.1, boosting decision trees improves their accuracy,
often dramatically. At the same time it maintains most of their desirable
properties for data mining. Some advantages of trees that are sacriﬁced by
boosting are speed, interpretability, and, for AdaBoost, robustness against
overlapping class distributions and especially mislabeling of the training
data. A gradient boosted model (GBM) is a generalization of tree boosting
that attempts to mitigate these problems, so as to produce an accurate and
eﬀective oﬀ-the-shelf procedure for data mining.

10.8 Example: Spam Data

Before we go into the details of gradient boosting, we demonstrate its abili-
ties on a two-class classiﬁcation problem. The spam data are introduced in
Chapter 1, and used as an example for many of the procedures in Chapter 9
(Sections 9.1.2, 9.2.5, 9.3.1 and 9.4.1).

Applying gradient boosting to these data resulted in a test error rate of
4.5%, using the same test set as was used in Section 9.1.2. By comparison,
an additive logistic regression achieved 5.5%, a CART tree fully grown and

10.9 Boosting Trees

353

pruned by cross-validation 8.7%, and MARS 5.5%. The standard error of
these estimates is around 0.6%, although gradient boosting is signiﬁcantly
better than all of them using the McNemar test (Exercise 10.6).

In Section 10.13 below we develop a relative importance measure for
each predictor, as well as a partial dependence plot describing a predictor’s
contribution to the ﬁtted model. We now illustrate these for the spam data.
Figure 10.6 displays the relative importance spectrum for all 57 predictor
variables. Clearly some predictors are more important than others in sep-
arating spam from email. The frequencies of the character strings !, $, hp,
and remove are estimated to be the four most relevant predictor variables.
At the other end of the spectrum, the character strings 857, 415, table, and
3d have virtually no relevance.

The quantity being modeled here is the log-odds of spam versus email

f (x) = log

Pr(spam
|
Pr(email
|

x)
x)

(10.24)

(see Section 10.13 below). Figure 10.7 shows the partial dependence of the
log-odds on selected important predictors, two positively associated with
spam (! and remove), and two negatively associated (edu and hp). These
particular dependencies are seen to be essentially monotonic. There is a
general agreement with the corresponding functions found by the additive
logistic regression model; see Figure 9.1 on page 303.

Running a gradient boosted model on these data with J = 2 terminal-
node trees produces a purely additive (main eﬀects) model for the log-
odds, with a corresponding error rate of 4.7%, as compared to 4.5% for the
full gradient boosted model (with J = 5 terminal-node trees). Although
not signiﬁcant, this slightly higher error rate suggests that there may be
interactions among some of the important predictor variables. This can
be diagnosed through two-variable partial dependence plots. Figure 10.8
shows one of the several such plots displaying strong interaction eﬀects.

One sees that for very low frequencies of hp, the log-odds of spam are
greatly increased. For high frequencies of hp, the log-odds of spam tend to
be much lower and roughly constant as a function of !. As the frequency
of hp decreases, the functional relationship with ! strengthens.

10.9 Boosting Trees

Regression and classiﬁcation trees are discussed in detail in Section 9.2.
They partition the space of all joint predictor variable values into disjoint
regions Rj, j = 1, 2, . . . , J, as represented by the terminal nodes of the tree.
A constant γj is assigned to each such region and the predictive rule is

x

Rj ⇒

∈

f (x) = γj.

354

10. Boosting and Additive Trees

3d
addresses
labs
telnet
857
415
direct
cs
table
85
#
parts
credit
[
lab
conference
report
original
data
project
font
make
address
order
all
hpl
technology
people
pm
mail
over
650
;
meeting
email
000
internet
receive
(
re
business
1999
will
money
our
you
edu
CAPTOT
george
CAPMAX
your
CAPAVE
free
remove
hp
$
!

0

20

40

60

80

100

Relative Importance

FIGURE 10.6. Predictor variable importance spectrum for the spam data. The
variable names are written on the vertical axis.

0.0

0.2

0.4

0.6

0.8

1.0

!

e
c
n
e
d
n
e
p
e
D

l

a
i
t
r
a
P

e
c
n
e
d
n
e
p
e
D

l

a

i
t
r
a
P

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

2
.
0
-

2
.
0

0
.
0

2
.

0
-

6

.

0
-

0

.

1
-

10.9 Boosting Trees

355

0.0

0.2

0.4

0.6

remove

e
c
n
e
d
n
e
p
e
D

l

a
i
t
r
a
P

e
c
n
e
d
n
e
p
e
D

l

a

i
t
r
a
P

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

2
.
0
-

2
.
0

0
.
0

.

2
0
-

6

.

0
-

0

.

1
-

0.0

0.2

0.4

0.6

0.8

1.0

0.0

0.5

1.0

edu

2.0

2.5

3.0

1.5

hp

FIGURE 10.7. Partial dependence of log-odds of spam on four important pre-
dictors. The red ticks at the base of the plots are deciles of the input variable.

 1.0

 0.5

 0.0

-0.5

-1.0

1.0

0.8

0.6

0.4

0.2

!

3.0

2.5

2.0

1.0

0.5

1.5

hp

FIGURE 10.8. Partial dependence of the log-odds of spam vs. email as a func-
tion of joint frequencies of hp and the character !.

 
 
 
 
356

10. Boosting and Additive Trees

Thus a tree can be formally expressed as

T (x; Θ) =

J

j=1
X

γjI(x

Rj),

∈

(10.25)

with parameters Θ =
The parameters are found by minimizing the empirical risk

J
1 . J is usually treated as a meta-parameter.

Rj, γj}
{

ˆΘ = arg min
Θ

J

j=1
X

Xxi∈Rj

L(yi, γj).

(10.26)

This is a formidable combinatorial optimization problem, and we usually
settle for approximate suboptimal solutions. It is useful to divide the opti-
mization problem into two parts:

Finding γj given Rj: Given the Rj, estimating the γj is typically trivial,
and often ˆγj = ¯yj, the mean of the yi falling in region Rj. For mis-
classiﬁcation loss, ˆγj is the modal class of the observations falling in
region Rj.

Finding Rj: This is the diﬃcult part, for which approximate solutions are
found. Note also that ﬁnding the Rj entails estimating the γj as well.
A typical strategy is to use a greedy, top-down recursive partitioning
algorithm to ﬁnd the Rj. In addition, it is sometimes necessary to
approximate (10.26) by a smoother and more convenient criterion for
optimizing the Rj:

˜Θ = arg min
Θ

N

˜L(yi, T (xi, Θ)).

(10.27)

i=1
X
Then given the ˆRj = ˜Rj, the γj can be estimated more precisely
using the original criterion.

In Section 9.2 we described such a strategy for classiﬁcation trees. The Gini
index replaced misclassiﬁcation loss in the growing of the tree (identifying
the Rj).

The boosted tree model is a sum of such trees,

M

fM (x) =

T (x; Θm),

(10.28)

m=1
X
induced in a forward stagewise manner (Algorithm 10.2). At each step in
the forward stagewise procedure one must solve

ˆΘm = arg min
Θm

N

i=1
X

L (yi, fm−1(xi) + T (xi; Θm))

(10.29)

10.9 Boosting Trees

357

for the region set and constants Θm =
the current model fm−1(x).

Rjm, γjm}
{

Jm
1

of the next tree, given

Given the regions Rjm, ﬁnding the optimal constants γjm in each region

is typically straightforward:

ˆγjm = arg min
γjm

Xxi∈Rjm

L (yi, fm−1(xi) + γjm) .

(10.30)

Finding the regions is diﬃcult, and even more diﬃcult than for a single
tree. For a few special cases, the problem simpliﬁes.

For squared-error loss, the solution to (10.29) is no harder than for a
single tree. It is simply the regression tree that best predicts the current
fm−1(xi), and ˆγjm is the mean of these residuals in each
residuals yi −
corresponding region.

For two-class classiﬁcation and exponential loss, this stagewise approach
gives rise to the AdaBoost method for boosting classiﬁcation trees (Algo-
rithm 10.1). In particular, if the trees T (x; Θm) are restricted to be scaled
classiﬁcation trees, then we showed in Section 10.4 that the solution to
=
I(yi 6
(10.29) is the tree that minimizes the weighted error rate
T (xi; Θm)) with weights w(m)
= e−yifm−1(xi). By a scaled classiﬁcation
tree, we mean βmT (x; Θm), with the restriction that γjm ∈ {−
weighted exponential criterion for the new tree:

Without this restriction, (10.29) still simpliﬁes for exponential loss to a

i=1 w(m)

).
1, 1
}

P

N

i

i

ˆΘm = arg min
Θm

N

i=1
X

w(m)
i

exp[

−

yiT (xi; Θm)].

(10.31)

It is straightforward to implement a greedy recursive-partitioning algorithm
using this weighted exponential loss as a splitting criterion. Given the Rjm,
one can show (Exercise 10.7) that the solution to (10.30) is the weighted
log-odds in each corresponding region

ˆγjm =

1
2

log

xi∈Rjm

P

xi∈Rjm

w(m)
i
w(m)
i

I(yi = 1)

I(yi =

1)

−

.

(10.32)

This requires a specialized tree-growing algorithm; in practice, we prefer
the approximation presented below that uses a weighted least squares re-
gression tree.

P

Using loss criteria such as the absolute error or the Huber loss (10.23) in
place of squared-error loss for regression, and the deviance (10.22) in place
of exponential loss for classiﬁcation, will serve to robustify boosting trees.
Unfortunately, unlike their nonrobust counterparts, these robust criteria
do not give rise to simple fast boosting algorithms.

For more general loss criteria the solution to (10.30), given the Rjm,
is typically straightforward since it is a simple “location” estimate. For

358

10. Boosting and Additive Trees

absolute loss it is just the median of the residuals in each respective region.
For the other criteria fast iterative algorithms exist for solving (10.30),
and usually their faster “single-step” approximations are adequate. The
problem is tree induction. Simple fast algorithms do not exist for solving
(10.29) for these more general loss criteria, and approximations like (10.27)
become essential.

10.10 Numerical Optimization via Gradient

Boosting

Fast approximate algorithms for solving (10.29) with any diﬀerentiable loss
criterion can be derived by analogy to numerical optimization. The loss in
using f (x) to predict y on the training data is

N

L(f ) =

L(yi, f (xi)).

(10.33)

i=1
X

The goal is to minimize L(f ) with respect to f , where here f (x) is con-
strained to be a sum of trees (10.28). Ignoring this constraint, minimizing
(10.33) can be viewed as a numerical optimization

ˆf = arg min

f

L(f ),

(10.34)

where the “parameters” f
tion f (xi) at each of the N data points xi:

∈

IRN are the values of the approximating func-

f =

f (x1), f (x2), . . . , f (xN )
{

T .
}

Numerical optimization procedures solve (10.34) as a sum of component

vectors

M

fM =

hm , hm ∈

IRN ,

m=0
X

where f0 = h0 is an initial guess, and each successive fm is induced based
on the current parameter vector fm−1, which is the sum of the previously
induced updates. Numerical optimization methods diﬀer in their prescrip-
tions for computing each increment vector hm (“step”).

10.10.1 Steepest Descent

IRN
Steepest descent chooses hm =
is the gradient of L(f ) evaluated at f = fm−1. The components of the
gradient gm are

ρmgm where ρm is a scalar and gm ∈

−

gim =

∂L(yi, f (xi))
∂f (xi)

(cid:20)

(cid:21)f (xi)=fm−1(xi)

(10.35)

10.10 Numerical Optimization via Gradient Boosting

359

The step length ρm is the solution to

ρm = arg min

ρ

L(fm−1 −

ρgm).

(10.36)

The current solution is then updated

fm = fm−1 −

ρmgm

and the process repeated at the next iteration. Steepest descent can be
gm is the local direction in IRN
viewed as a very greedy strategy, since
for which L(f ) is most rapidly decreasing at f = fm−1.

−

10.10.2 Gradient Boosting

Forward stagewise boosting (Algorithm 10.2) is also a very greedy strategy.
At each step the solution tree is the one that maximally reduces (10.29),
given the current model fm−1 and its ﬁts fm−1(xi). Thus, the tree predic-
tions T (xi; Θm) are analogous to the components of the negative gradient
(10.35). The principal diﬀerence between them is that the tree components
T are not independent. They are con-
tm =
}
strained to be the predictions of a Jm-terminal node decision tree, whereas
the negative gradient is the unconstrained maximal descent direction.

T (x1; Θm), . . . , T (xN ; Θm)
{

The solution to (10.30) in the stagewise approach is analogous to the line
search (10.36) in steepest descent. The diﬀerence is that (10.30) performs
a separate line search for those components of tm that correspond to each
separate terminal region

If minimizing loss on the training data (10.33) were the only goal, steep-
est descent would be the preferred strategy. The gradient (10.35) is trivial
to calculate for any diﬀerentiable loss function L(y, f (x)), whereas solving
(10.29) is diﬃcult for the robust criteria discussed in Section 10.6. Unfor-
tunately the gradient (10.35) is deﬁned only at the training data points xi,
whereas the ultimate goal is to generalize fM (x) to new data not repre-
sented in the training set.

A possible resolution to this dilemma is to induce a tree T (x; Θm) at the
mth iteration whose predictions tm are as close as possible to the negative
gradient. Using squared error to measure closeness, this leads us to

˜Θm = arg min
Θ

N

i=1
X

(

gim −

−

T (xi; Θ))2 .

(10.37)

That is, one ﬁts the tree T to the negative gradient values (10.35) by least
squares. As noted in Section 10.9 fast algorithms exist for least squares
decision tree induction. Although the solution regions ˜Rjm to (10.37) will
not be identical to the regions Rjm that solve (10.29), it is generally sim-
ilar enough to serve the same purpose. In any case, the forward stagewise

T (xi; Θm)
{

}xi∈Rjm.

360

10. Boosting and Additive Trees

TABLE 10.2. Gradients for commonly used loss functions.

Setting

Loss Function

Regression

Regression

Regression

f (xi)]2

f (xi)

|

1

2 [yi −
yi −
|
Huber

∂L(yi, f (xi))/∂f (xi)

f (xi)

f (xi)]

−
yi −
sign[yi −
yi −
f (xi) for
δmsign[yi −
where δm = αth-quantile

yi −
f (xi)] for

f (xi)

|

|

Classiﬁcation Deviance

kth component: I(yi =

δm
f (xi)
yi −

> δm

|
f (xi)

|}

pk(xi)

−

| ≤
yi −
{|
Gk)

boosting procedure, and top-down decision tree induction, are themselves
approximation procedures. After constructing the tree (10.37), the corre-
sponding constants in each region are given by (10.30).

Table 10.2 summarizes the gradients for commonly used loss functions.
For squared error loss, the negative gradient is just the ordinary residual
fm−1(xi), so that (10.37) on its own is equivalent to standard
gim = yi −
−
least-squares boosting. With absolute error loss, the negative gradient is
the sign of the residual, so at each iteration (10.37) ﬁts the tree to the
sign of the current residuals by least squares. For Huber M-regression, the
negative gradient is a compromise between these two (see the table).

For classiﬁcation the loss function is the multinomial deviance (10.22),
and K least squares trees are constructed at each iteration. Each tree Tkm
is ﬁt to its respective negative gradient vector gkm,

gikm =

−

∂L (yi, f1m(xi), . . . , f1m(xi))
∂fkm(xi)
pk(xi),

= I(yi =

Gk)
with pk(x) given by (10.21). Although K separate trees are built at each
iteration, they are related through (10.21). For binary classiﬁcation (K =
2), only one tree is needed (exercise 10.10).

(10.38)

−

10.10.3 Implementations of Gradient Boosting

Algorithm 10.3 presents the generic gradient tree-boosting algorithm for
regression. Speciﬁc algorithms are obtained by inserting diﬀerent loss cri-
teria L(y, f (x)). The ﬁrst line of the algorithm initializes to the optimal
constant model, which is just a single terminal node tree. The components
of the negative gradient computed at line 2(a) are referred to as general-
ized or pseudo residuals, r. Gradients for commonly used loss functions are
summarized in Table 10.2.

10.11 Right-Sized Trees for Boosting

361

Algorithm 10.3 Gradient Tree Boosting Algorithm.

1. Initialize f0(x) = arg minγ

N
i=1 L(yi, γ).

2. For m = 1 to M :

P

(a) For i = 1, 2, . . . , N compute

rim =

−

(cid:20)

∂L(yi, f (xi))
∂f (xi)

.

(cid:21)f =fm−1

(b) Fit a regression tree to the targets rim giving terminal regions

Rjm, j = 1, 2, . . . , Jm.

(c) For j = 1, 2, . . . , Jm compute

γjm = arg min

γ

Xxi∈Rjm

L (yi, fm−1(xi) + γ) .

(d) Update fm(x) = fm−1(x) +

Jm
j=1 γjmI(x

Rjm).

∈

3. Output ˆf (x) = fM (x).

P

The algorithm for classiﬁcation is similar. Lines 2(a)–(d) are repeated
K times at each iteration m, once for each class using (10.38). The result
at line 3 is K diﬀerent (coupled) tree expansions fkM (x), k = 1, 2, . . . , K.
These produce probabilities via (10.21) or do classiﬁcation as in (10.20).
Details are given in Exercise 10.9. Two basic tuning parameters are the
number of iterations M and the sizes of each of the constituent trees
Jm, m = 1, 2, . . . , M .

The original implementation of this algorithm was called MART for
“multiple additive regression trees,” and was referred to in the ﬁrst edi-
tion of this book. Many of the ﬁgures in this chapter were produced by
MART. Gradient boosting as described here is implemented in the R gbm
package (Ridgeway, 1999, “Gradient Boosted Models”), and is freely avail-
able. The gbm package is used in Section 10.14.2, and extensively in Chap-
ters 16 and 15. Another R implementation of boosting is mboost (Hothorn
and B¨uhlmann, 2006). A commercial implementation of gradient boost-
ing/MART called TreeNet(cid:226)

is available from Salford Systems, Inc.

10.11 Right-Sized Trees for Boosting

Historically, boosting was considered to be a technique for combining mod-
els, here trees. As such, the tree building algorithm was regarded as a

362

10. Boosting and Additive Trees

primitive that produced models to be combined by the boosting proce-
dure. In this scenario, the optimal size of each tree is estimated separately
in the usual manner when it is built (Section 9.2). A very large (oversized)
tree is ﬁrst induced, and then a bottom-up procedure is employed to prune
it to the estimated optimal number of terminal nodes. This approach as-
sumes implicitly that each tree is the last one in the expansion (10.28).
Except perhaps for the very last tree, this is clearly a very poor assump-
tion. The result is that trees tend to be much too large, especially during
the early iterations. This substantially degrades performance and increases
computation.

The simplest strategy for avoiding this problem is to restrict all trees
to be the same size, Jm = J
m. At each iteration a J-terminal node
regression tree is induced. Thus J becomes a meta-parameter of the entire
boosting procedure, to be adjusted to maximize estimated performance for
the data at hand.

∀

One can get an idea of useful values for J by considering the properties

of the “target” function

η = arg min

f

EXY L(Y, f (X)).

(10.39)

Here the expected value is over the population joint distribution of (X, Y ).
The target function η(x) is the one with minimum prediction risk on future
data. This is the function we are trying to approximate.

One relevant property of η(X) is the degree to which the coordinate vari-
ables X T = (X1, X2, . . . , Xp) interact with one another. This is captured
by its ANOVA (analysis of variance) expansion

η(X) =

ηj(Xj) +

ηjk(Xj, Xk) +

ηjkl(Xj, Xk, Xl) +

j
X

Xjk

Xjkl

. (10.40)

· · ·

The ﬁrst sum in (10.40) is over functions of only a single predictor variable
Xj. The particular functions ηj(Xj) are those that jointly best approximate
η(X) under the loss criterion being used. Each such ηj(Xj) is called the
“main eﬀect” of Xj. The second sum is over those two-variable functions
that when added to the main eﬀects best ﬁt η(X). These are called the
second-order interactions of each respective variable pair (Xj, Xk). The
third sum represents third-order interactions, and so on. For many problems
encountered in practice, low-order interaction eﬀects tend to dominate.
When this is the case, models that produce strong higher-order interaction
eﬀects, such as large decision trees, suﬀer in accuracy.

The interaction level of tree-based approximations is limited by the tree
size J. Namely, no interaction eﬀects of level greater than J
1 are pos-
sible. Since boosted models are additive in the trees (10.28), this limit
extends to them as well. Setting J = 2 (single split “decision stump”)
produces boosted models with only main eﬀects; no interactions are per-
mitted. With J = 3, two-variable interaction eﬀects are also allowed, and

−

10.11 Right-Sized Trees for Boosting

363

Stumps
10 Node
100 Node
Adaboost

r
o
r
r

E

t
s
e
T

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

0

100

200

300

400

Number of Terms

FIGURE 10.9. Boosting with diﬀerent sized trees, applied to the example (10.2)
used in Figure 10.2. Since the generative model is additive, stumps perform the
best. The boosting algorithm used the binomial deviance loss in Algorithm 10.3;
shown for comparison is the AdaBoost Algorithm 10.1.

so on. This suggests that the value chosen for J should reﬂect the level
of dominant interactions of η(x). This is of course generally unknown, but
in most situations it will tend to be low. Figure 10.9 illustrates the eﬀect
of interaction order (choice of J) on the simulation example (10.2). The
generative function is additive (sum of quadratic monomials), so boosting
models with J > 2 incurs unnecessary variance and hence the higher test
error. Figure 10.10 compares the coordinate functions found by boosted
stumps with the true functions.

Although in many applications J = 2 will be insuﬃcient, it is unlikely
that J > 10 will be required. Experience so far indicates that 4
8
works well in the context of boosting, with results being fairly insensitive
to particular choices in this range. One can ﬁne-tune the value for J by
trying several diﬀerent values and choosing the one that produces the low-
est risk on a validation sample. However, this seldom provides signiﬁcant
improvement over using J

≤

≤

6.

J

≃

 
364

10. Boosting and Additive Trees

Coordinate Functions for Additive Logistic Trees

f1(x1)

f2(x2)

f3(x3)

f4(x4)

f5(x5)

f6(x6)

f7(x7)

f8(x8)

f9(x9)

f10(x10)

FIGURE 10.10. Coordinate functions estimated by boosting stumps for the sim-
ulated example used in Figure 10.9. The true quadratic functions are shown for
comparison.

10.12 Regularization

Besides the size of the constituent trees, J, the other meta-parameter of
gradient boosting is the number of boosting iterations M . Each iteration
usually reduces the training risk L(fM ), so that for M large enough this risk
can be made arbitrarily small. However, ﬁtting the training data too well
can lead to overﬁtting, which degrades the risk on future predictions. Thus,
there is an optimal number M ∗ minimizing future risk that is application
dependent. A convenient way to estimate M ∗ is to monitor prediction risk
as a function of M on a validation sample. The value of M that minimizes
this risk is taken to be an estimate of M ∗. This is analogous to the early
stopping strategy often used with neural networks (Section 11.4).

10.12.1 Shrinkage

Controlling the value of M is not the only possible regularization strategy.
As with ridge regression and neural networks, shrinkage techniques can be
employed as well (see Sections 3.4.1 and 11.5). The simplest implementation
of shrinkage in the context of boosting is to scale the contribution of each
tree by a factor 0 < ν < 1 when it is added to the current approximation.
That is, line 2(d) of Algorithm 10.3 is replaced by

fm(x) = fm−1(x) + ν

J

·

j=1
X

γjmI(x

Rjm).

∈

(10.41)

The parameter ν can be regarded as controlling the learning rate of the
boosting procedure. Smaller values of ν (more shrinkage) result in larger
training risk for the same number of iterations M . Thus, both ν and M
control prediction risk on the training data. However, these parameters do

10.12 Regularization

365

not operate independently. Smaller values of ν lead to larger values of M
for the same training risk, so that there is a tradeoﬀ between them.

Empirically it has been found (Friedman, 2001) that smaller values of ν
favor better test error, and require correspondingly larger values of M . In
fact, the best strategy appears to be to set ν to be very small (ν < 0.1)
and then choose M by early stopping. This yields dramatic improvements
(over no shrinkage ν = 1) for regression and for probability estimation. The
corresponding improvements in misclassiﬁcation risk via (10.20) are less,
but still substantial. The price paid for these improvements is computa-
tional: smaller values of ν give rise to larger values of M , and computation
is proportional to the latter. However, as seen below, many iterations are
generally computationally feasible even on very large data sets. This is
partly due to the fact that small trees are induced at each step with no
pruning.

Figure 10.11 shows test error curves for the simulated example (10.2) of
Figure 10.2. A gradient boosted model (MART) was trained using binomial
deviance, using either stumps or six terminal-node trees, and with or with-
out shrinkage. The beneﬁts of shrinkage are evident, especially when the
binomial deviance is tracked. With shrinkage, each test error curve reaches
a lower value, and stays there for many iterations.

Section 16.2.1 draws a connection between forward stagewise shrinkage
in boosting and the use of an L1 penalty for regularizing model parame-
ters (the “lasso”). We argue that L1 penalties may be superior to the L2
penalties used by methods such as the support vector machine.

10.12.2 Subsampling

We saw in Section 8.7 that bootstrap averaging (bagging) improves the
performance of a noisy classiﬁer through averaging. Chapter 15 discusses
in some detail the variance-reduction mechanism of this sampling followed
by averaging. We can exploit the same device in gradient boosting, both
to improve performance and computational eﬃciency.

With stochastic gradient boosting (Friedman, 1999), at each iteration we
sample a fraction η of the training observations (without replacement),
and grow the next tree using that subsample. The rest of the algorithm is
identical. A typical value for η can be 1
2 , although for large N , η can be
substantially smaller than 1
2 .

Not only does the sampling reduce the computing time by the same
fraction η, but in many cases it actually produces a more accurate model.
Figure 10.12 illustrates the eﬀect of subsampling using the simulated
example (10.2), both as a classiﬁcation and as a regression example. We
see in both cases that sampling along with shrinkage slightly outperformed
the rest. It appears here that subsampling without shrinkage does poorly.

366

10. Boosting and Additive Trees

Stumps
Deviance

No shrinkage
Shrinkage=0.2

r
o
r
r

E
n
o

i
t

a
c
i
f
i
s
s
a
c
s
M

l

i

t

e
S

t
s
e
T

Stumps
Misclassification Error

No shrinkage
Shrinkage=0.2

5

.

0

4
0

.

3

.

0

2
0

.

1

.

0

0
.
0

0

500

1000

1500

2000

0

500

1000

1500

2000

Boosting Iterations

Boosting Iterations

6-Node Trees
Deviance

No shrinkage
Shrinkage=0.6

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

l

i

t
e
S

t
s
e
T

6-Node Trees
Misclassification Error

No shrinkage
Shrinkage=0.6

5
.
0

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

e
c
n
a
v
e
D

i

t

e
S

t
s
e
T

e
c
n
a
v
e
D

i

t
e
S

t
s
e
T

0

.

2

5

.

1

0

.

1

5

.

0

0
.
0

0
.
2

5
.
1

0
.
1

5
.
0

0
.
0

0

500

1000

1500

2000

0

500

1000

1500

2000

Boosting Iterations

Boosting Iterations

FIGURE 10.11. Test error curves for simulated example (10.2) of Figure 10.9,
using gradient boosting (MART). The models were trained using binomial de-
viance, either stumps or six terminal-node trees, and with or without shrinkage.
The left panels report test deviance, while the right panels show misclassiﬁcation
error. The beneﬁcial eﬀect of shrinkage can be seen in all cases, especially for
deviance in the left panels.

 
 
 
 
 
 
 
 
 
 
10.13 Interpretation

367

4−Node Trees

Deviance

Absolute Error

0
5
.
0

5
4
.
0

0
4
.
0

5
3
.
0

0
3
.
0

r
o
r
r

E
e
t
u
o
s
b
A

l

t
e
S

t
s
e
T

No shrinkage
Shrink=0.1
Sample=0.5
Shrink=0.1 Sample=0.5

e
c
n
a
v
e
D

i

t
e
S

t
s
e
T

4
.
1

2
.
1

0
.
1

8
.
0

6
.
0

4
.
0

0

200

400

600

800

1000

0

200

400

600

800

1000

Boosting Iterations

Boosting Iterations

FIGURE 10.12. Test-error curves for the simulated example (10.2), showing
the eﬀect of stochasticity. For the curves labeled “Sample= 0.5”, a diﬀerent 50%
subsample of the training data was used each time a tree was grown. In the left
panel the models were ﬁt by gbm using a binomial deviance loss function; in the
right-hand panel using square-error loss.

The downside is that we now have four parameters to set: J, M , ν and
η. Typically some early explorations determine suitable values for J, ν and
η, leaving M as the primary parameter.

10.13

Interpretation

Single decision trees are highly interpretable. The entire model can be com-
pletely represented by a simple two-dimensional graphic (binary tree) that
is easily visualized. Linear combinations of trees (10.28) lose this important
feature, and must therefore be interpreted in a diﬀerent way.

10.13.1 Relative Importance of Predictor Variables

In data mining applications the input predictor variables are seldom equally
relevant. Often only a few of them have substantial inﬂuence on the re-
sponse; the vast majority are irrelevant and could just as well have not
been included. It is often useful to learn the relative importance or contri-
bution of each input variable in predicting the response.

 
 
 
 
 
368

10. Boosting and Additive Trees

For a single decision tree T , Breiman et al. (1984) proposed

2
ℓ (T ) =

I

J−1

t=1
X

ˆı2
t I(v(t) = ℓ)

(10.42)

−

as a measure of relevance for each predictor variable Xℓ. The sum is over
the J
1 internal nodes of the tree. At each such node t, one of the input
variables Xv(t) is used to partition the region associated with that node into
two subregions; within each a separate constant is ﬁt to the response values.
The particular variable chosen is the one that gives maximal estimated
improvement ˆı2
t in squared error risk over that for a constant ﬁt over the
entire region. The squared relative importance of variable Xℓ is the sum of
such squared improvements over all internal nodes for which it was chosen
as the splitting variable.

This importance measure is easily generalized to additive tree expansions

(10.28); it is simply averaged over the trees

2
ℓ =

I

1
M

M

I

2
ℓ (Tm).

(10.43)

m=1
X
Due to the stabilizing eﬀect of averaging, this measure turns out to be more
reliable than is its counterpart (10.42) for a single tree. Also, because of
shrinkage (Section 10.12.1) the masking of important variables by others
with which they are highly correlated is much less of a problem. Note
that (10.42) and (10.43) refer to squared relevance; the actual relevances
are their respective square roots. Since these measures are relative, it is
customary to assign the largest a value of 100 and then scale the others
accordingly. Figure 10.6 shows the relevant importance of the 57 inputs in
predicting spam versus email.

For K-class classiﬁcation, K separate models fk(x), k = 1, 2, . . . , K are

induced, each consisting of a sum of trees

M

fk(x) =

Tkm(x).

(10.44)

In this case (10.43) generalizes to

2
ℓk =

I

1
M

m=1
X

M

I

m=1
X

2
ℓ (Tkm).

(10.45)

Here
Iℓk is the relevance of Xℓ in separating the class k observations from
the other classes. The overall relevance of Xℓ is obtained by averaging over
all of the classes

K

2
ℓ =

I

1
K

2
ℓk.

I

Xk=1

(10.46)

10.13 Interpretation

369

Figures 10.23 and 10.24 illustrate the use of these averaged and separate
relative importances.

10.13.2 Partial Dependence Plots

After the most relevant variables have been identiﬁed, the next step is to
attempt to understand the nature of the dependence of the approximation
f (X) on their joint values. Graphical renderings of the f (X) as a function
of its arguments provides a comprehensive summary of its dependence on
the joint values of the input variables.

Unfortunately, such visualization is limited to low-dimensional views.
We can easily display functions of one or two arguments, either continuous
or discrete (or mixed), in a variety of diﬀerent ways; this book is ﬁlled
with such displays. Functions of slightly higher dimensions can be plotted
by conditioning on particular sets of values of all but one or two of the
arguments, producing a trellis of plots (Becker et al., 1996).1

For more than two or three variables, viewing functions of the corre-
sponding higher-dimensional arguments is more diﬃcult. A useful alterna-
tive can sometimes be to view a collection of plots, each one of which shows
the partial dependence of the approximation f (X) on a selected small sub-
set of the input variables. Although such a collection can seldom provide a
comprehensive depiction of the approximation, it can often produce helpful
clues, especially when f (x) is dominated by low-order interactions (10.40).
Consider the subvector XS of ℓ < p of the input predictor variables X T =
be the complement
(X1, X2, . . . , Xp), indexed by
S ⊂ {
C
set, with
. A general function f (X) will in principle
1, 2, . . . , p
}
{
depend on all of the input variables: f (X) = f (XS , XC). One way to deﬁne
the average or partial dependence of f (X) on XS is

. Let
}

1, 2, . . . , p

S ∪ C

=

fS (XS ) = EXC f (XS , XC).

(10.47)

This is a marginal average of f , and can serve as a useful description of the
eﬀect of the chosen subset on f (X) when, for example, the variables in XS
do not have strong interactions with those in XC.

Partial dependence functions can be used to interpret the results of any

“black box” learning method. They can be estimated by

¯fS (XS ) =

1
N

N

i=1
X

f (XS , xiC),

(10.48)

x1C, x2C, . . . , xN C}
{

where
are the values of XC occurring in the training
data. This requires a pass over the data for each set of joint values of XS for
which ¯fS (XS ) is to be evaluated. This can be computationally intensive,

1lattice in R.

370

10. Boosting and Additive Trees

even for moderately sized data sets. Fortunately with decision trees, ¯fS (XS )
(10.48) can be rapidly computed from the tree itself without reference to
the data (Exercise 10.11).

It is important to note that partial dependence functions deﬁned in
(10.47) represent the eﬀect of XS on f (X) after accounting for the (av-
erage) eﬀects of the other variables XC on f (X). They are not the eﬀect
of XS on f (X) ignoring the eﬀects of XC. The latter is given by the con-
ditional expectation

˜fS (XS ) = E(f (XS , XC)

XS ),

|

(10.49)

and is the best least squares approximation to f (X) by a function of XS
alone. The quantities ˜fS (XS ) and ¯fS (XS ) will be the same only in the
unlikely event that XS and XC are independent. For example, if the eﬀect
of the chosen variable subset happens to be purely additive,

f (X) = h1(XS ) + h2(XC).

(10.50)

Then (10.47) produces the h1(XS ) up to an additive constant. If the eﬀect
is purely multiplicative,

f (X) = h1(XS )

h2(XC),

·

(10.51)

then (10.47) produces h1(XS ) up to a multiplicative constant factor. On
the other hand, (10.49) will not produce h1(XS ) in either case. In fact,
(10.49) can produce strong eﬀects on variable subsets for which f (X) has
no dependence at all.

Viewing plots of the partial dependence of the boosted-tree approxima-
tion (10.28) on selected variables subsets can help to provide a qualitative
description of its properties. Illustrations are shown in Sections 10.8 and
10.14. Owing to the limitations of computer graphics, and human percep-
1, 2, 3). There are of
tion, the size of the subsets XS must be small (l
course a large number of such subsets, but only those chosen from among
the usually much smaller set of highly relevant predictors are likely to be
informative. Also, those subsets whose eﬀect on f (X) is approximately
additive (10.50) or multiplicative (10.51) will be most revealing.

≈

For K-class classiﬁcation, there are K separate models (10.44), one for
each class. Each one is related to the respective probabilities (10.21) through

fk(X) = log pk(X)

1
K

−

K

Xl=1

log pl(X).

(10.52)

Thus each fk(X) is a monotone increasing function of its respective prob-
ability on a logarithmic scale. Partial dependence plots of each respective
fk(X) (10.44) on its most relevant predictors (10.45) can help reveal how
the log-odds of realizing that class depend on the respective input variables.

10.14 Illustrations

371

10.14

Illustrations

In this section we illustrate gradient boosting on a number of larger datasets,
using diﬀerent loss functions as appropriate.

10.14.1 California Housing

This data set (Pace and Barry, 1997) is available from the Carnegie-Mellon
StatLib repository2. It consists of aggregated data from each of 20,460
neighborhoods (1990 census block groups) in California. The response vari-
able Y is the median house value in each neighborhood measured in units of
$100,000. The predictor variables are demographics such as median income
MedInc, housing density as reﬂected by the number of houses House, and the
average occupancy in each house AveOccup. Also included as predictors are
the location of each neighborhood (longitude and latitude), and several
quantities reﬂecting the properties of the houses in the neighborhood: av-
erage number of rooms AveRooms and bedrooms AveBedrms. There are thus
a total of eight predictors, all numeric.

We ﬁt a gradient boosting model using the MART procedure, with J = 6
terminal nodes, a learning rate (10.41) of ν = 0.1, and the Huber loss
criterion for predicting the numeric response. We randomly divided the
dataset into a training set (80%) and a test set (20%).

Figure 10.13 shows the average absolute error

AAE = E

y

|

−

ˆfM (x)

|

(10.53)

as a function for number of iterations M on both the training data and test
data. The test error is seen to decrease monotonically with increasing M ,
more rapidly during the early stages and then leveling oﬀ to being nearly
constant as iterations increase. Thus, the choice of a particular value of M
is not critical, as long as it is not too small. This tends to be the case in
many applications. The shrinkage strategy (10.41) tends to eliminate the
problem of overﬁtting, especially for larger data sets.

The value of AAE after 800 iterations is 0.31. This can be compared to
which is 0.89. In terms of
that of the optimal constant predictor median
more familiar quantities, the squared multiple correlation coeﬃcient of this
model is R2 = 0.84. Pace and Barry (1997) use a sophisticated spatial auto-
regression procedure, where prediction for each neighborhood is based on
median house values in nearby neighborhoods, using the other predictors as
covariates. Experimenting with transformations they achieved R2 = 0.85,
predicting log Y . Using log Y as the response the corresponding value for
gradient boosting was R2 = 0.86.

yi}
{

2http://lib.stat.cmu.edu.

372

10. Boosting and Additive Trees

Training and Test Absolute Error

Train Error
Test Error

r
o
r
r

E
e
t
u
o
s
b
A

l

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

0

200

400

600

800

Iterations M

FIGURE 10.13. Average-absolute error as a function of number of iterations
for the California housing data.

Figure 10.14 displays the relative variable importances for each of the
eight predictor variables. Not surprisingly, median income in the neigh-
borhood is the most relevant predictor. Longitude, latitude, and average
occupancy all have roughly half the relevance of income, whereas the others
are somewhat less inﬂuential.

Figure 10.15 shows single-variable partial dependence plots on the most
relevant nonlocation predictors. Note that the plots are not strictly smooth.
This is a consequence of using tree-based models. Decision trees produce
discontinuous piecewise constant models (10.25). This carries over to sums
of trees (10.28), with of course many more pieces. Unlike most of the meth-
ods discussed in this book, there is no smoothness constraint imposed on
the result. Arbitrarily sharp discontinuities can be modeled. The fact that
these curves generally exhibit a smooth trend is because that is what is
estimated to best predict the response for this problem. This is often the
case.

The hash marks at the base of each plot delineate the deciles of the
data distribution of the corresponding variables. Note that here the data
density is lower near the edges, especially for larger values. This causes the
curves to be somewhat less well determined in those regions. The vertical
scales of the plots are the same, and give a visual comparison of the relative
importance of the diﬀerent variables.

The partial dependence of median house value on median income is
monotonic increasing, being nearly linear over the main body of data. House
value is generally monotonic decreasing with increasing average occupancy,
except perhaps for average occupancy rates less than one. Median house

 
10.14 Illustrations

373

Population

AveBedrms

AveRooms

HouseAge

Latitude

AveOccup

Longitude

MedInc

0

20

40

60

80

100

Relative importance

FIGURE 10.14. Relative importance of the predictors for the California housing
data.

value has a nonmonotonic partial dependence on average number of rooms.
It has a minimum at approximately three rooms and is increasing both for
smaller and larger values.

Median house value is seen to have a very weak partial dependence on
house age that is inconsistent with its importance ranking (Figure 10.14).
This suggests that this weak main eﬀect may be masking stronger interac-
tion eﬀects with other variables. Figure 10.16 shows the two-variable partial
dependence of housing value on joint values of median age and average oc-
cupancy. An interaction between these two variables is apparent. For values
of average occupancy greater than two, house value is nearly independent
of median age, whereas for values less than two there is a strong dependence
on age.

Figure 10.17 shows the two-variable partial dependence of the ﬁtted
model on joint values of longitude and latitude, displayed as a shaded
contour plot. There is clearly a very strong dependence of median house
value on the neighborhood location in California. Note that Figure 10.17 is
not a plot of house value versus location ignoring the eﬀects of the other
predictors (10.49). Like all partial dependence plots, it represents the eﬀect
of location after accounting for the eﬀects of the other neighborhood and
house attributes (10.47). It can be viewed as representing an extra premium
one pays for location. This premium is seen to be relatively large near the
Paciﬁc coast especially in the Bay Area and Los Angeles–San Diego re-

374

10. Boosting and Additive Trees

0
.
2

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

e
c
n
e
d
n
e
p
e
D

l

a
i
t
r
a
P

e
c
n
e
d
n
e
p
e
D

l

a
i
t
r
a
P

2

4

6

8

10

MedInc

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
-

0
.
1
-

e
c
n
e
d
n
e
p
e
D

l

a
i
t
r
a
P

e
c
n
e
d
n
e
p
e
D

l

a
i
t
r
a
P

2

3

4

5

AveOccup

10

20

30

40

50

4

6

8

10

HouseAge

AveRooms

FIGURE 10.15. Partial dependence of housing value on the nonlocation vari-
ables for the California housing data. The red ticks at the base of the plot are
deciles of the input variables.

1.0

0.5

0.0

50

40

30

HouseAge

20

10

4

5

AveOccup

2

3

FIGURE 10.16. Partial dependence of house value on median age and aver-
age occupancy. There appears to be a strong interaction eﬀect between these two
variables.

 
 
 
 
2
4

0
4

8
3

6
3

4
3

e
d
u
t
i
t
a
L

10.14 Illustrations

375

 1.0

 0.5

 0.0

−0.5

−1.0

−124

−122

−120

−118

−116

−114

Longitude

FIGURE 10.17. Partial dependence of median house value on location in Cal-
ifornia. One unit is $100, 000, at 1990 prices, and the values plotted are relative
to the overall median of $180, 000.

gions. In the northern, central valley, and southeastern desert regions of
California, location costs considerably less.

10.14.2 New Zealand Fish

Plant and animal ecologists use regression models to predict species pres-
ence, abundance and richness as a function of environmental variables.
Although for many years simple linear and parametric models were popu-
lar, recent literature shows increasing interest in more sophisticated mod-
els such as generalized additive models (Section 9.1, GAM), multivariate
adaptive regression splines (Section 9.4, MARS) and boosted regression
trees (Leathwick et al., 2005; Leathwick et al., 2006). Here we model the

376

10. Boosting and Additive Trees

presence and abundance of the Black Oreo Dory, a marine ﬁsh found in the
oceanic waters around New Zealand.3

Figure 10.18 shows the locations of 17,000 trawls (deep-water net ﬁshing,
with a maximum depth of 2km), and the red points indicate those 2353
trawls for which the Black Oreo was present, one of over a hundred species
regularly recorded. The catch size in kg for each species was recorded for
each trawl. Along with the species catch, a number of environmental mea-
surements are available for each trawl. These include the average depth of
the trawl (AvgDepth), and the temperature and salinity of the water. Since
the latter two are strongly correlated with depth, Leathwick et al. (2006)
derived instead TempResid and SalResid, the residuals obtained when these
two measures are adjusted for depth (via separate non-parametric regres-
sions). SSTGrad is a measure of the gradient of the sea surface temperature,
and Chla is a broad indicator of ecosytem productivity via satellite-image
measurements. SusPartMatter provides a measure of suspended particulate
matter, particularly in coastal waters, and is also satellite derived.

The goal of this analysis is to estimate the probability of ﬁnding Black
Oreo in a trawl, as well as the expected catch size, standardized to take
into account the eﬀects of variation in trawl speed and distance, as well
as the mesh size of the trawl net. The authors used logistic regression
for estimating the probability. For the catch size, it might seem natural
to assume a Poisson distribution and model the log of the mean count,
but this is often not appropriate because of the excessive number of zeros.
Although specialized approaches have been developed, such as the zero-
inﬂated Poisson (Lambert, 1992), they chose a simpler approach. If Y is
the (non-negative) catch size,

E(Y

|

X) = E(Y

|

Y > 0, X)

Pr(Y > 0
|

·

X).

(10.54)

The second term is estimated by the logistic regression, and the ﬁrst term
can be estimated using only the 2353 trawls with a positive catch.

For the logistic regression the authors used a gradient boosted model
(GBM)4 with binomial deviance loss function, depth-10 trees, and a shrink-
age factor ν = 0.025. For the positive-catch regression, they modeled
log(Y ) using a GBM with squared-error loss (also depth-10 trees, but
ν = 0.01), and un-logged the predictions. In both cases they used 10-fold
cross-validation for selecting the number of terms, as well as the shrinkage
factor.

3The models, data, and maps shown here were kindly provided by Dr John Leathwick
of the National Institute of Water and Atmospheric Research in New Zealand, and Dr
Jane Elith, School of Botany, University of Melbourne. The collection of the research
trawl data took place from 1979–2005, and was funded by the New Zealand Ministry of
Fisheries.

4Version 1.5-7 of package gbm in R, ver. 2.2.0.

10.14 Illustrations

377

FIGURE 10.18. Map of New Zealand and its surrounding exclusive economic
zone, showing the locations of 17,000 trawls (small blue dots) taken between 1979
and 2005. The red points indicate trawls for which the species Black Oreo Dory
were present.

378

10. Boosting and Additive Trees

i

e
c
n
a
v
e
D
n
a
e
M

4
3
.
0

2
3
.
0

0
3
.
0

8
2
.
0

6
2
.
0

4
2
.
0

GBM Test
GBM CV
GAM Test

y
t
i
v
i
t
i
s
n
e
S

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

AUC

GAM 0.97
GBM 0.98

0

500

1000

1500

0.0

0.2

0.4

0.6

0.8

1.0

Number of Trees

Specificity

FIGURE 10.19. The left panel shows the mean deviance as a function of the
number of trees for the GBM logistic regression model ﬁt to the presence/absence
data. Shown are 10-fold cross-validation on the training data (and 1
s.e. bars),
and test deviance on the test data. Also shown for comparison is the test deviance
using a GAM model with 8 df for each term. The right panel shows ROC curves
on the test data for the chosen GBM model (vertical line in left plot) and the
GAM model.

×

Figure 10.19 (left panel) shows the mean binomial deviance for the se-
quence of GBM models, both for 10-fold CV and test data. There is a mod-
est improvement over the performance of a GAM model, ﬁt using smoothing
splines with 8 degrees-of-freedom (df) per term. The right panel shows the
ROC curves (see Section 9.2.5) for both models, which measures predictive
performance. From this point of view, the performance looks very simi-
lar, with GBM perhaps having a slight edge as summarized by the AUC
(area under the curve). At the point of equal sensitivity/speciﬁcity, GBM
achieves 91%, and GAM 90%.

Figure 10.20 summarizes the contributions of the variables in the logistic
GBM ﬁt. We see that there is a well-deﬁned depth range over which Black
Oreo are caught, with much more frequent capture in colder waters. We do
not give details of the quantitative catch model; the important variables
were much the same.

All the predictors used in these models are available on a ﬁne geographi-
cal grid; in fact they were derived from environmental atlases, satellite im-
ages and the like—see Leathwick et al. (2006) for details. This also means
that predictions can be made on this grid, and imported into GIS mapping
systems. Figure 10.21 shows prediction maps for both presence and catch
size, with both standardized to a common set of trawl conditions; since the
predictors vary in a continuous fashion with geographical location, so do
the predictions.

 
TempResid
AvgDepth
SusPartMatter
SalResid
SSTGrad
ChlaCase2
Slope
TidalCurr
Pentade
CodendSize
DisOrgMatter
Distance
Speed
OrbVel

i

)
d
s
e
R
p
m
e
T
(
f

0 10

25

Relative influence

)
r
e

t
t

a
M

t
r
a
P
s
u
S

(
f

3
−

5
−

7
−

i

)
d
s
e
R
a
S

l

(
f

10.14 Illustrations

379

t

)
h
p
e
D
g
v
A

(
f

2
−

4
−

6
−

−4

0

2

4

6

0

500 1000

2000

TempResid

AvgDepth

1
−

3
−

5
−

7
−

)
d
a
r
G
T
S
S

(
f

1
−

3
−

5
−

7
−

1
−

3
−

5
−

7
−

0

5

10

15

−0.8

−0.4

0.0

0.4

0.00

0.05

0.10

0.15

SusPartMatter

SalResid

SSTGrad

FIGURE 10.20. The top-left panel shows the relative inﬂuence computed from
the GBM logistic regression model. The remaining panels show the partial de-
pendence plots for the leading ﬁve variables, all plotted on the same scale for
comparison.

Because of their ability to model interactions and automatically select
variables, as well as robustness to outliers and missing data, GBM models
are rapidly gaining popularity in this data-rich and enthusiastic community.

10.14.3 Demographics Data

In this section we illustrate gradient boosting on a multiclass classiﬁca-
tion problem, using MART. The data come from 9243 questionnaires ﬁlled
out by shopping mall customers in the San Francisco Bay Area (Impact
Resources, Inc., Columbus, OH). Among the questions are 14 concerning
demographics. For this illustration the goal is to predict occupation us-
ing the other 13 variables as predictors, and hence identify demographic
variables that discriminate between diﬀerent occupational categories. We
randomly divided the data into a training set (80%) and test set (20%),
and used J = 6 node trees with a learning rate ν = 0.1.

Figure 10.22 shows the K = 9 occupation class values along with their
corresponding error rates. The overall error rate is 42.5%, which can be
compared to the null rate of 69% obtained by predicting the most numerous

380

10. Boosting and Additive Trees

FIGURE 10.21. Geological prediction maps of the presence probability (left
map) and catch size (right map) obtained from the gradient boosted models.

class Prof/Man (Professional/Managerial). The four best predicted classes
are seen to be Retired, Student, Prof/Man, and Homemaker.

Figure 10.23 shows the relative predictor variable importances as aver-
aged over all classes (10.46). Figure 10.24 displays the individual relative
importance distributions (10.45) for each of the four best predicted classes.
One sees that the most relevant predictors are generally diﬀerent for each
respective class. An exception is age which is among the three most relevant
for predicting Retired, Student, and Prof/Man.

Figure 10.25 shows the partial dependence of the log-odds (10.52) on age
for these three classes. The abscissa values are ordered codes for respective
equally spaced age intervals. One sees that after accounting for the contri-
butions of the other variables, the odds of being retired are higher for older
people, whereas the opposite is the case for being a student. The odds of
being professional/managerial are highest for middle-aged people. These
results are of course not surprising. They illustrate that inspecting partial
dependences separately for each class can lead to sensible results.

Bibliographic Notes

Schapire (1990) developed the ﬁrst simple boosting procedure in the PAC
learning framework (Valiant, 1984; Kearns and Vazirani, 1994). Schapire

10.14 Illustrations

381

Overall Error Rate = 0.425

Student

Retired

Prof/Man

Homemaker

Labor

Clerical

Military

Unemployed

Sales

0.0

0.2

0.4

0.6

0.8

1.0

Error Rate

FIGURE 10.22. Error rate for each occupation in the demographics data.

yrs-BA

children

num-hsld

lang

typ-home

mar-stat

ethnic

sex

mar-dlinc

hsld-stat

edu

income

age

0

20

40

60

80

100

Relative Importance

FIGURE 10.23. Relative importance of the predictors as averaged over all
classes for the demographics data.

382

10. Boosting and Additive Trees

Class =  Retired

Class =  Student

children
yrs-BA
lang
mar-dlinc
sex
typ-home
num-hsld
ethnic
edu
mar-stat
income
age
hsld-stat

0

20

40

60

80

100

0

20

40

60

80

100

Relative Importance

Relative Importance

Class =  Prof/Man

Class =  Homemaker

yrs-BA
hsld-stat
age
income
typ-home
lang
mar-stat
edu
num-hsld
ethnic
children
mar-dlinc
sex

yrs-BA
num-hsld
edu
children
typ-home
lang
mar-stat
hsld-stat
income
ethnic
sex
mar-dlinc
age

children
yrs-BA
mar-stat
lang
num-hsld
sex
typ-home
hsld-stat
ethnic
mar-dlinc
age
income
edu

0

20

40

60

80

100

0

20

40

60

80

100

Relative Importance

Relative Importance

FIGURE 10.24. Predictor variable importances separately for each of the four
classes with lowest error rate for the demographics data.

Retired

Student

10.14 Illustrations

383

e
c
n
e
d
n
e
p
e
D

l

a
i
t
r
a
P

2

1

0

1
-

2
-

1

2

3

4

age

Prof/Man

5

6

7

1

2

3

5

6

7

4

age

e
c
n
e
d
n
e
p
e
D

l

a
i
t
r
a
P

e
c
n
e
d
n
e
p
e
D

l

a
i
t
r
a
P

4

3

2

1

0

2

1

0

1
-

2
-

1

2

3

5

6

7

4

age

FIGURE 10.25. Partial dependence of the odds of three diﬀerent occupations
on age, for the demographics data.

showed that a weak learner could always improve its performance by train-
ing two additional classiﬁers on ﬁltered versions of the input data stream.
A weak learner is an algorithm for producing a two-class classiﬁer with
performance guaranteed (with high probability) to be signiﬁcantly better
than a coin-ﬂip. After learning an initial classiﬁer G1 on the ﬁrst N training
points,

G2 is learned on a new sample of N points, half of which are misclas-
siﬁed by G1;

G3 is learned on N points for which G1 and G2 disagree;

the boosted classiﬁer is GB = majority vote(G1, G2, G3).

•

•

•

Schapire’s “Strength of Weak Learnability” theorem proves that GB has
improved performance over G1.

Freund (1995) proposed a “boost by majority” variation which combined
many weak learners simultaneously and improved the performance of the
simple boosting algorithm of Schapire. The theory supporting both of these

 
 
 
384

10. Boosting and Additive Trees

algorithms requires the weak learner to produce a classiﬁer with a ﬁxed
error rate. This led to the more adaptive and realistic AdaBoost (Freund
and Schapire, 1996a) and its oﬀspring, where this assumption was dropped.
Freund and Schapire (1996a) and Schapire and Singer (1999) provide
some theory to support their algorithms, in the form of upper bounds on
generalization error. This theory has evolved in the computational learning
community, initially based on the concepts of PAC learning. Other theo-
ries attempting to explain boosting come from game theory (Freund and
Schapire, 1996b; Breiman, 1999; Breiman, 1998), and VC theory (Schapire
et al., 1998). The bounds and the theory associated with the AdaBoost
algorithms are interesting, but tend to be too loose to be of practical im-
portance. In practice, boosting achieves results far more impressive than
the bounds would imply. Schapire (2002) and Meir and R¨atsch (2003) give
useful overviews more recent than the ﬁrst edition of this book.

Friedman et al. (2000) and Friedman (2001) form the basis for our expo-
sition in this chapter. Friedman et al. (2000) analyze AdaBoost statistically,
derive the exponential criterion, and show that it estimates the log-odds
of the class probability. They propose additive tree models, the right-sized
trees and ANOVA representation of Section 10.11, and the multiclass logit
formulation. Friedman (2001) developed gradient boosting and shrinkage
for classiﬁcation and regression, while Friedman (1999) explored stochastic
variants of boosting. Mason et al. (2000) also embraced a gradient approach
to boosting. As the published discussions of Friedman et al. (2000) shows,
there is some controversy about how and why boosting works.

Since the publication of the ﬁrst edition of this book, these debates have
continued, and spread into the statistical community with a series of papers
on consistency of boosting (Jiang, 2004; Lugosi and Vayatis, 2004; Zhang
and Yu, 2005; Bartlett and Traskin, 2007). Mease and Wyner (2008),
through a series of simulation examples, challenge some of our interpre-
tations of boosting; our response (Friedman et al., 2008a) puts most of
these objections to rest. A recent survey by B¨uhlmann and Hothorn (2007)
supports our approach to boosting.

Exercises

Ex. 10.1 Derive expression (10.12) for the update parameter in AdaBoost.

Ex. 10.2 Prove result (10.16), that is, the minimizer of the population
version of the AdaBoost criterion, is one-half of the log odds.

Ex. 10.3 Show that the marginal average (10.47) recovers additive and
multiplicative functions (10.50) and (10.51), while the conditional expec-
tation (10.49) does not.

Exercises

385

Ex. 10.4

(a) Write a program implementing AdaBoost with trees.

(b) Redo the computations for the example of Figure 10.2. Plot the train-

ing error as well as test error, and discuss its behavior.

(c) Investigate the number of iterations needed to make the test error

ﬁnally start to rise.

(d) Change the setup of this example as follows: deﬁne two classes, with
the features in Class 1 being X1, X2, . . . , X10, standard indepen-
dent Gaussian variates. In Class 2, the features X1, X2, . . . , X10 are
also standard independent Gaussian, but conditioned on the event
j > 12. Now the classes have signiﬁcant overlap in feature space.
Repeat the AdaBoost experiments as in Figure 10.2 and discuss the
P
results.

j X 2

Ex. 10.5 Multiclass exponential loss (Zhu et al., 2005). For a K-class clas-
siﬁcation problem, consider the coding Y = (Y1, . . . , YK )T with

Yk =

(cid:26)

Let f = (f1, . . . , fK )T with

1,

1
K−1 ,

if G =
Gk
otherwise.

−
K
k=1 fk = 0, and deﬁne

(10.55)

P
L(Y, f ) = exp

1
K

−

Y T f

.

(10.56)

(cid:18)
(a) Using Lagrange multipliers, derive the population minimizer f ∗ of
E(Y, f ), subject to the zero-sum constraint, and relate these to the
class probabilities.

(cid:19)

(b) Show that a multiclass boosting using this loss function leads to a
reweighting algorithm similar to Adaboost, as in Section 10.4.

Ex. 10.6 McNemar test (Agresti, 1996). We report the test error rates on
the spam data to be 5.5% for a generalized additive model (GAM), and
4.5% for gradient boosting (GBM), with a test sample of size 1536.

(a) Show that the standard error of these estimates is about 0.6%.

Since the same test data are used for both methods, the error rates are
correlated, and we cannot perform a two-sample t-test. We can compare
the methods directly on each test observation, leading to the summary

GAM
Correct
Error

GBM
Correct Error
18
51

1434
33

386

10. Boosting and Additive Trees

The McNemar test focuses on the discordant errors, 33 vs. 18.

(b) Conduct a test to show that GAM makes signiﬁcantly more errors

than gradient boosting, with a two-sided p-value of 0.036.

Ex. 10.7 Derive expression (10.32).

Ex. 10.8 Consider a K-class problem where the targets yik are coded as
1 if observation i is in class k and zero otherwise. Suppose we have a
K
current model fk(x), k = 1, . . . , K, with
k=1 fk(x) = 0 (see (10.21) in
Section 10.6). We wish to update the model for observations in a region R
in predictor space, by adding constants fk(x) + γk, with γK = 0.

P

(a) Write down the multinomial log-likelihood for this problem, and its

ﬁrst and second derivatives.

(b) Using only the diagonal of the Hessian matrix in (1), and starting
k, show that a one-step approximate Newton update

from γk = 0
for γk is

∀

γ1
k =

xi∈R(yik −
xi∈R pik(1
P
−
P
where pik = exp(fk(xi))/ exp(

pik)
pik)

K
ℓ=1 fℓ(xi)).

, k = 1, . . . , K

1,

−

(10.57)

(c) We prefer our update to sum to zero, as the current model does. Using
P
symmetry arguments, show that

ˆγk =

1

K

−
K

(γ1

k −

1
K

Xℓ=1

K

γ1
ℓ ), k = 1, . . . , K

(10.58)

is an appropriate update, where γ1
k = 1, . . . , K.

k is deﬁned as in (10.57) for all

Ex. 10.9 Consider a K-class problem where the targets yik are coded as
1 if observation i is in class k and zero otherwise. Using the multinomial
deviance loss function (10.22) and the symmetric logistic transform, use
the arguments leading to the gradient boosting Algorithm 10.3 to derive
Algorithm 10.4. Hint: See exercise 10.8 for step 2(b)iii.

Ex. 10.10 Show that for K = 2 class classiﬁcation, only one tree needs to
be grown at each gradient-boosting iteration.

Ex. 10.11 Show how to compute the partial dependence function fS (XS )
in (10.47) eﬃciently.

Ex. 10.12 Referring to (10.49), let
, with f (X1, X2) =
2
=
}
{
X1. Assume X1 and X2 are bivariate Gaussian, each with mean zero, vari-
X2) = ρX2, even
ance one, and E(X1, X2) = ρ. Show that E(f (X1, X2|
though f is not a function of X2.

1
}
{

and

=

S

C

Exercises

387

Algorithm 10.4 Gradient Boosting for K-class Classiﬁcation.

1. Initialize fk0(x) = 0, k = 1, 2, . . . , K.

2. For m=1 to M :

(a) Set

pk(x) =

efk(x)
K
ℓ=1 efℓ(x)

, k = 1, 2, . . . , K.

(b) For k = 1 to K:

P

i. Compute rikm = yik −
ii. Fit a regression tree to the targets rikm, i = 1, 2, . . . , N ,

pk(xi), i = 1, 2, . . . , N .

giving terminal regions Rjkm, j = 1, 2, . . . , Jm.

iii. Compute

γjkm =

1

K

−
K

xi∈Rjkm

P
xi∈Rjkm |

rikm|

rikm
(1

− |

, j = 1, 2, . . . , Jm.

rikm|

)

iv. Update fkm(x) = fk,m−1(x) +

P

Jm
j=1 γjkmI(x

Rjkm).

∈

3. Output ˆfk(x) = fkM (x), k = 1, 2, . . . , K.

P

388

10. Boosting and Additive Trees

11
Neural Networks

This is page 389
Printer: Opaque this

11.1

Introduction

In this chapter we describe a class of learning methods that was developed
separately in diﬀerent ﬁelds—statistics and artiﬁcial intelligence—based
on essentially identical models. The central idea is to extract linear com-
binations of the inputs as derived features, and then model the target as
a nonlinear function of these features. The result is a powerful learning
method, with widespread applications in many ﬁelds. We ﬁrst discuss the
projection pursuit model, which evolved in the domain of semiparamet-
ric statistics and smoothing. The rest of the chapter is devoted to neural
network models.

11.2 Projection Pursuit Regression

As in our generic supervised learning problem, assume we have an input
vector X with p components, and a target Y . Let ωm, m = 1, 2, . . . , M, be
unit p-vectors of unknown parameters. The projection pursuit regression
(PPR) model has the form

M

f (X) =

gm(ωT

mX).

(11.1)

m=1
X
This is an additive model, but in the derived features Vm = ωT
mX rather
than the inputs themselves. The functions gm are unspeciﬁed and are esti-

390

Neural Networks

g(V )

g(V )

X2

X1

X2

X1

FIGURE 11.1. Perspective plots of two ridge functions.
(Left:) g(V ) = 1/[1 + exp(
5(V
(Right:) g(V ) = (V + 0.1) sin(1/(V /3 + 0.1)), where V = X1.

0.5))], where V = (X1 + X2)/√2.

−

−

mated along with the directions ωm using some ﬂexible smoothing method
(see below).

The function gm(ωT

mX) is called a ridge function in IRp. It varies only
in the direction deﬁned by the vector ωm. The scalar variable Vm = ωT
mX
is the projection of X onto the unit vector ωm, and we seek ωm so that
the model ﬁts well, hence the name “projection pursuit.” Figure 11.1 shows
some examples of ridge functions. In the example on the left ω = (1/√2)(1, 1)T ,
so that the function only varies in the direction X1 + X2. In the example
on the right, ω = (1, 0).

The PPR model (11.1) is very general, since the operation of forming
nonlinear functions of linear combinations generates a surprisingly large
class of models. For example, the product X1 ·
X2 can be written as [(X1 +
X2)2
X2)2]/4, and higher-order products can be represented simi-
larly.

(X1 −

−

In fact, if M is taken arbitrarily large, for appropriate choice of gm the
PPR model can approximate any continuous function in IRp arbitrarily
well. Such a class of models is called a universal approximator. However
this generality comes at a price. Interpretation of the ﬁtted model is usually
diﬃcult, because each input enters into the model in a complex and multi-
faceted way. As a result, the PPR model is most useful for prediction, and
not very useful for producing an understandable model for the data. The
M = 1 model, known as the single index model in econometrics, is an
exception. It is slightly more general than the linear regression model, and
oﬀers a similar interpretation.

How do we ﬁt a PPR model, given training data (xi, yi), i = 1, 2, . . . , N ?

We seek the approximate minimizers of the error function

N

M

yi −

i=1"
X

m=1
X

gm(ωT

mxi)

2

#

(11.2)

11.2 Projection Pursuit Regression

391

over functions gm and direction vectors ωm, m = 1, 2, . . . , M . As in other
smoothing problems, we need either explicitly or implicitly to impose com-
plexity constraints on the gm, to avoid overﬁt solutions.

Consider just one term (M = 1, and drop the subscript). Given the
direction vector ω, we form the derived variables vi = ωT xi. Then we have
a one-dimensional smoothing problem, and we can apply any scatterplot
smoother, such as a smoothing spline, to obtain an estimate of g.

On the other hand, given g, we want to minimize (11.2) over ω. A Gauss–
Newton search is convenient for this task. This is a quasi-Newton method,
in which the part of the Hessian involving the second derivative of g is
discarded. It can be simply derived as follows. Let ωold be the current
estimate for ω. We write

g(ωT xi)

≈

g(ωT

oldxi) + g′(ωT

oldxi)(ω

ωold)T xi

−

(11.3)

to give

N

g(ωT xi)

2

yi −

≈

N

g′(ωT

oldxi)2

ωT

oldxi +

yi −

g(ωT

oldxi)

2

.

ωT xi

g′(ωT

oldxi)

−

i=1
X

(cid:2)

(cid:3)

i=1
X

(cid:21)
(11.4)
To minimize the right-hand side, we carry out a least squares regression
oldxi) on the input xi, with weights
oldxi)2 and no intercept (bias) term. This produces the updated coef-

oldxi +(yi −

oldxi))/g′(ωT

g(ωT

(cid:20)(cid:18)

(cid:19)

with target ωT
g′(ωT
ﬁcient vector ωnew.

These two steps, estimation of g and ω, are iterated until convergence.
With more than one term in the PPR model, the model is built in a forward
stage-wise manner, adding a pair (ωm, gm) at each stage.

There are a number of implementation details.

•

•

•

•

Although any smoothing method can in principle be used, it is conve-
nient if the method provides derivatives. Local regression and smooth-
ing splines are convenient.

After each step the gm’s from previous steps can be readjusted using
the backﬁtting procedure described in Chapter 9. While this may
lead ultimately to fewer terms, it is not clear whether it improves
prediction performance.

Usually the ωm are not readjusted (partly to avoid excessive compu-
tation), although in principle they could be as well.

The number of terms M is usually estimated as part of the forward
stage-wise strategy. The model building stops when the next term
does not appreciably improve the ﬁt of the model. Cross-validation
can also be used to determine M .

392

Neural Networks

There are many other applications, such as density estimation (Friedman
et al., 1984; Friedman, 1987), where the projection pursuit idea can be used.
In particular, see the discussion of ICA in Section 14.7 and its relationship
with exploratory projection pursuit. However the projection pursuit re-
gression model has not been widely used in the ﬁeld of statistics, perhaps
because at the time of its introduction (1981), its computational demands
exceeded the capabilities of most readily available computers. But it does
represent an important intellectual advance, one that has blossomed in its
reincarnation in the ﬁeld of neural networks, the topic of the rest of this
chapter.

11.3 Neural Networks

The term neural network has evolved to encompass a large class of models
and learning methods. Here we describe the most widely used “vanilla” neu-
ral net, sometimes called the single hidden layer back-propagation network,
or single layer perceptron. There has been a great deal of hype surrounding
neural networks, making them seem magical and mysterious. As we make
clear in this section, they are just nonlinear statistical models, much like
the projection pursuit regression model discussed above.

A neural network is a two-stage regression or classiﬁcation model, typ-
ically represented by a network diagram as in Figure 11.2. This network
applies both to regression or classiﬁcation. For regression, typically K = 1
and there is only one output unit Y1 at the top. However, these networks
can handle multiple quantitative responses in a seamless fashion, so we will
deal with the general case.

For K-class classiﬁcation, there are K units at the top, with the kth
unit modeling the probability of class k. There are K target measurements
Yk, k = 1, . . . , K, each being coded as a 0

1 variable for the kth class.

Derived features Zm are created from linear combinations of the inputs,
and then the target Yk is modeled as a function of linear combinations of
the Zm,

−

Zm = σ(α0m + αT
Tk = β0k + βT

k Z, k = 1, . . . , K,

mX), m = 1, . . . , M,

(11.5)

fk(X) = gk(T ), k = 1, . . . , K,

where Z = (Z1, Z2, . . . , ZM ), and T = (T1, T2, . . . , TK ).

The activation function σ(v) is usually chosen to be the sigmoid σ(v) =
1/(1 + e−v); see Figure 11.3 for a plot of 1/(1 + e−v). Sometimes Gaussian
radial basis functions (Chapter 6) are used for the σ(v), producing what is
known as a radial basis function network.

Neural network diagrams like Figure 11.2 are sometimes drawn with an
additional bias unit feeding into every unit in the hidden and output layers.

11.3 Neural Networks

393

(cid:1)
(cid:0)
(cid:1)
(cid:0)
(cid:1)
(cid:0)
(cid:1)
(cid:0)
(cid:1)
(cid:0)
(cid:1)
(cid:0)
(cid:0)
(cid:1)
(cid:0)
(cid:1)
(cid:0)
(cid:1)
(cid:0)
(cid:1)
(cid:0)
(cid:1)
(cid:0)
(cid:1)

 Y
 Y
1
1

 Y
 Y
2
2

 Y
 Y
K
K

 Z1
 Z1

 Z2
 Z2

 Z
 Z

3
3

 Z
 Z
M
m

 X X
1
1

 X
 X2
2

 X
 X3
3

 X p-1
 X p-1

 Xp
 X
p

FIGURE 11.2. Schematic of a single hidden layer, feed-forward neural network.

Thinking of the constant “1” as an additional input feature, this bias unit
captures the intercepts α0m and β0k in model (11.5).

The output function gk(T ) allows a ﬁnal transformation of the vector of
outputs T . For regression we typically choose the identity function gk(T ) =
Tk. Early work in K-class classiﬁcation also used the identity function, but
this was later abandoned in favor of the softmax function

gk(T ) =

eTk
K
ℓ=1 eTℓ

.

(11.6)

P
This is of course exactly the transformation used in the multilogit model
(Section 4.4), and produces positive estimates that sum to one. In Sec-
tion 4.2 we discuss other problems with linear activation functions, in par-
ticular potentially severe masking eﬀects.

The units in the middle of the network, computing the derived features
Zm, are called hidden units because the values Zm are not directly ob-
served. In general there can be more than one hidden layer, as illustrated
in the example at the end of this chapter. We can think of the Zm as a
basis expansion of the original inputs X; the neural network is then a stan-
dard linear model, or linear multilogit model, using these transformations
as inputs. There is, however, an important enhancement over the basis-
expansion techniques discussed in Chapter 5; here the parameters of the
basis functions are learned from the data.

                                                                                                                                                
394

Neural Networks

)
v
−
e
+
1
(
/
1

0
.
1

5
.
0

0
.
0

-10

-5

5

10

0

v

FIGURE 11.3. Plot of the sigmoid function σ(v) = 1/(1+exp(
v)) (red curve),
commonly used in the hidden layer of a neural network. Included are σ(sv) for
s = 1
2 (blue curve) and s = 10 (purple curve). The scale parameter s controls
the activation rate, and we can see that large s amounts to a hard activation at
v = 0. Note that σ(s(v

v0)) shifts the activation threshold from 0 to v0.

−

−

Notice that if σ is the identity function, then the entire model collapses
to a linear model in the inputs. Hence a neural network can be thought of
as a nonlinear generalization of the linear model, both for regression and
classiﬁcation. By introducing the nonlinear transformation σ, it greatly
enlarges the class of linear models. In Figure 11.3 we see that the rate of
activation of the sigmoid depends on the norm of αm, and if
is very
small, the unit will indeed be operating in the linear part of its activation
function.

αmk
k

Notice also that the neural network model with one hidden layer has
exactly the same form as the projection pursuit model described above.
The diﬀerence is that the PPR model uses nonparametric functions gm(v),
while the neural network uses a far simpler function based on σ(v), with
three free parameters in its argument. In detail, viewing the neural network
model as a PPR model, we identify

gm(ωT

mX) = βmσ(α0m + αT

mX)
αmk
k
where ωm = αm/
is the mth unit-vector. Since σβ,α0,s(v) = βσ(α0 +
αmk
k
sv) has lower complexity than a more general nonparametric g(v), it is not
surprising that a neural network might use 20 or 100 such functions, while
the PPR model typically uses fewer terms (M = 5 or 10, for example).

= βmσ(α0m +

mX)),

(11.7)

(ωT

Finally, we note that the name “neural networks” derives from the fact
that they were ﬁrst developed as models for the human brain. Each unit
represents a neuron, and the connections (links in Figure 11.2) represent
synapses. In early models, the neurons ﬁred when the total signal passed to
that unit exceeded a certain threshold. In the model above, this corresponds

11.4 Fitting Neural Networks

395

to use of a step function for σ(Z) and gm(T ). Later the neural network was
recognized as a useful tool for nonlinear statistical modeling, and for this
purpose the step function is not smooth enough for optimization. Hence the
step function was replaced by a smoother threshold function, the sigmoid
in Figure 11.3.

11.4 Fitting Neural Networks

The neural network model has unknown parameters, often called weights,
and we seek values for them that make the model ﬁt the training data well.
We denote the complete set of weights by θ, which consists of

α0m, αm; m = 1, 2, . . . , M
{
β0k, βk; k = 1, 2, . . . , K
{

}
}

M (p + 1) weights,
K(M + 1) weights.

(11.8)

For regression, we use sum-of-squared errors as our measure of ﬁt (error
function)

R(θ) =

K

N

Xk=1

i=1
X

(yik −

fk(xi))2.

(11.9)

For classiﬁcation we use either squared error or cross-entropy (deviance):

R(θ) =

−

N

K

i=1
X

Xk=1

yik log fk(xi),

(11.10)

and the corresponding classiﬁer is G(x) = argmaxkfk(x). With the softmax
activation function and the cross-entropy error function, the neural network
model is exactly a linear logistic regression model in the hidden units, and
all the parameters are estimated by maximum likelihood.

Typically we don’t want the global minimizer of R(θ), as this is likely
to be an overﬁt solution. Instead some regularization is needed: this is
achieved directly through a penalty term, or indirectly by early stopping.
Details are given in the next section.

The generic approach to minimizing R(θ) is by gradient descent, called
back-propagation in this setting. Because of the compositional form of the
model, the gradient can be easily derived using the chain rule for diﬀeren-
tiation. This can be computed by a forward and backward sweep over the
network, keeping track only of quantities local to each unit.

396

Neural Networks

Here is back-propagation in detail for squared error loss. Let zmi =
mxi), from (11.5) and let zi = (z1i, z2i, . . . , zM i). Then we have

σ(α0m + αT

R(θ)

≡

=

N

Ri

i=1
X
N

K

(yik −

Xk=1

i=1
X

fk(xi))2,

with derivatives

∂Ri
∂βkm

∂Ri
∂αmℓ

=

2(yik −

−

fk(xi))g′

k(βT

k zi)zmi,

=

−

K

Xk=1

2(yik −

fk(xi))g′

k(βT

k zi)βkmσ′(αT

mxi)xiℓ.

(11.11)

(11.12)

Given these derivatives, a gradient descent update at the (r + 1)st iter-

ation has the form

km = β(r)
β(r+1)

km −

mℓ = α(r)
α(r+1)

mℓ −

γr

γr

N

i=1
X
N

i=1
X

∂Ri
∂β(r)
km

,

∂Ri
∂α(r)
mℓ

,

where γr is the learning rate, discussed below.

Now write (11.12) as

∂Ri
∂βkm
∂Ri
∂αmℓ

= δkizmi,

= smixiℓ.

(11.13)

(11.14)

The quantities δki and smi are “errors” from the current model at the
output and hidden layer units, respectively. From their deﬁnitions, these
errors satisfy

smi = σ′(αT

mxi)

K

Xk=1

βkmδki,

(11.15)

known as the back-propagation equations. Using this, the updates in (11.13)
can be implemented with a two-pass algorithm. In the forward pass, the
current weights are ﬁxed and the predicted values ˆfk(xi) are computed
from formula (11.5). In the backward pass, the errors δki are computed,
and then back-propagated via (11.15) to give the errors smi. Both sets of
errors are then used to compute the gradients for the updates in (11.13),
via (11.14).

11.5 Some Issues in Training Neural Networks

397

This two-pass procedure is what is known as back-propagation. It has
also been called the delta rule (Widrow and Hoﬀ, 1960). The computational
components for cross-entropy have the same form as those for the sum of
squares error function, and are derived in Exercise 11.3.

The advantages of back-propagation are its simple, local nature. In the
back propagation algorithm, each hidden unit passes and receives infor-
mation only to and from units that share a connection. Hence it can be
implemented eﬃciently on a parallel architecture computer.

The updates in (11.13) are a kind of batch learning, with the parame-
ter updates being a sum over all of the training cases. Learning can also
be carried out online—processing each observation one at a time, updat-
ing the gradient after each training case, and cycling through the training
cases many times. In this case, the sums in equations (11.13) are replaced
by a single summand. A training epoch refers to one sweep through the
entire training set. Online training allows the network to handle very large
training sets, and also to update the weights as new observations come in.
The learning rate γr for batch learning is usually taken to be a con-
stant, and can also be optimized by a line search that minimizes the error
function at each update. With online learning γr should decrease to zero
as the iteration r
. This learning is a form of stochastic approxima-
tion (Robbins and Munro, 1951); results in this ﬁeld ensure convergence if
(satisﬁed, for example, by γr = 1/r).
γr →
Back-propagation can be very slow, and for that reason is usually not
the method of choice. Second-order techniques such as Newton’s method
are not attractive here, because the second derivative matrix of R (the
Hessian) can be very large. Better approaches to ﬁtting include conjugate
gradients and variable metric methods. These avoid explicit computation
of the second derivative matrix while still providing faster convergence.

r γr =

→ ∞

, and

r γ2

r <

P

P

∞

∞

0,

11.5 Some Issues in Training Neural Networks

There is quite an art in training neural networks. The model is generally
overparametrized, and the optimization problem is nonconvex and unstable
unless certain guidelines are followed. In this section we summarize some
of the important issues.

11.5.1 Starting Values

Note that if the weights are near zero, then the operative part of the sigmoid
(Figure 11.3) is roughly linear, and hence the neural network collapses into
an approximately linear model (Exercise 11.2). Usually starting values for
weights are chosen to be random values near zero. Hence the model starts
out nearly linear, and becomes nonlinear as the weights increase. Individual

398

Neural Networks

units localize to directions and introduce nonlinearities where needed. Use
of exact zero weights leads to zero derivatives and perfect symmetry, and
the algorithm never moves. Starting instead with large weights often leads
to poor solutions.

11.5.2 Overﬁtting

Often neural networks have too many weights and will overﬁt the data at
the global minimum of R. In early developments of neural networks, either
by design or by accident, an early stopping rule was used to avoid over-
ﬁtting. Here we train the model only for a while, and stop well before we
approach the global minimum. Since the weights start at a highly regular-
ized (linear) solution, this has the eﬀect of shrinking the ﬁnal model toward
a linear model. A validation dataset is useful for determining when to stop,
since we expect the validation error to start increasing.

A more explicit method for regularization is weight decay, which is anal-
ogous to ridge regression used for linear models (Section 3.4.1). We add a
penalty to the error function R(θ) + λJ(θ), where

J(θ) =

β2
km +

α2

mℓ

(11.16)

≥

Xkm

Xmℓ
and λ
0 is a tuning parameter. Larger values of λ will tend to shrink
the weights toward zero: typically cross-validation is used to estimate λ.
The eﬀect of the penalty is to simply add terms 2βkm and 2αmℓ to the
respective gradient expressions (11.13). Other forms for the penalty have
been proposed, for example,

J(θ) =

β2
km
1 + β2

km

+

α2
mℓ
1 + α2

mℓ

,

Xmℓ

Xkm

(11.17)

known as the weight elimination penalty. This has the eﬀect of shrinking
smaller weights more than (11.16) does.

Figure 11.4 shows the result of training a neural network with ten hidden
units, without weight decay (upper panel) and with weight decay (lower
panel), to the mixture example of Chapter 2. Weight decay has clearly
improved the prediction. Figure 11.5 shows heat maps of the estimated
weights from the training (grayscale versions of these are called Hinton
diagrams.) We see that weight decay has dampened the weights in both
layers: the resulting weights are spread fairly evenly over the ten hidden
units.

11.5.3 Scaling of the Inputs

Since the scaling of the inputs determines the eﬀective scaling of the weights
in the bottom layer, it can have a large eﬀect on the quality of the ﬁnal

11.5 Some Issues in Training Neural Networks

399

Neural Network - 10 Units, No Weight Decay

o

o

o

. . . . .

o
o

o
o
o
o

o
o
o
o

. . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
. . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
. . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
. . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
. . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
. . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
. . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . .
o o
. . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . . . .
. .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . .
. . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . .
. . . . .
. . .
.
. . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . .
o
o
o
oo
. . . . . . . . . . . . .
. . . . . .
. . . . .
.
. . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
oo
o
. . . . . . . . . . . . .
. . . . .
. . . . . . .
.
. . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . .
o
o
o
o
. . . . . . . . . . . .
. . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . .
o
o
o
. . . . . . . . .
. . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . .
. . . . .
. . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
o
o
o
o
. . . . . . . . . . .
. . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . .
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . .
. . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
oo
o
o
o
. . . . . . . . . .
. . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . .
o
o
o
. . . . . . . . . .
. . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
o
o
o
o
. . . . . . . . . .
. . . . . . . . . .
. . . . .
. . .
. . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . .
. . . . . . .
o
. . . . . . . . .
. . . . . . . . .
. . . . .
. . . .
. . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . .
. . . . . . .
o
o
o
. . . . . . . . .
. . . . .
. . . . . . .
. . . . . . . . .
. .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . .
. . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . .
o
. . . . . . . .
. . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . .
. . . . . . . . . . . . . . .
. . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . .
. . . . . . . .
. . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . .
. . . .
. . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . .
. . . . . .
. . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
. . . . . .
. . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
. . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . .
. . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . .
. . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
oo
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
.
. . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . .
. . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . .
. . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . .
. . . . . . . . . .
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . .
. . . . . . .
.
. . . . . . .
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . .
. . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.100
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.259
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o
o

o
o
o
o

o
o
o

o
o

o

o

o

Neural Network - 10 Units, Weight Decay=0.02 

o

o

o

o

o

o

o

o
o

o
o

o
o
o
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
.
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
.
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . .
o
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
o o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . .
o
o
o
oo
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . .
. .
o
oo
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . .
. . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . .
o
o
o
o
oo
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
. . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
o
. . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . .
o
o
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . .
o
o
o
. . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
o
o
. . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . .
o
oo
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.160
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.223
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. .. .. .. .. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o
o

o
o
o
o

o
o

o
o
o

o
o

o
o

o

o

o

o

o

FIGURE 11.4. A neural network on the mixture example of Chapter 2. The
upper panel uses no weight decay, and overﬁts the training data. The lower panel
uses weight decay, and achieves close to the Bayes error rate (broken purple
boundary). Both use the softmax activation function and cross-entropy error.

400

Neural Networks

No weight decay

Weight decay

y2
y1

1

1
z

2
z

3
z

1
z

5
z

6
z

7
z

8
z

9
z

0
1
z

1

1
z

2
z

3
z

1
z

5
z

6
z

7
z

8
z

9
z

0
1
z

x2

x1

1

y2
y1

x2

x1

1

1
z

2
z

3
z

1
z

5
z

6
z

7
z

8
z

9
z

0
1
z

1
z

2
z

3
z

1
z

5
z

6
z

7
z

8
z

9
z

0
1
z

FIGURE 11.5. Heat maps of the estimated weights from the training of neural
networks from Figure 11.4. The display ranges from bright green (negative) to
bright red (positive).

solution. At the outset it is best to standardize all inputs to have mean zero
and standard deviation one. This ensures all inputs are treated equally in
the regularization process, and allows one to choose a meaningful range for
the random starting weights. With standardized inputs, it is typical to take
random uniform weights over the range [

0.7, +0.7].

−

11.5.4 Number of Hidden Units and Layers

Generally speaking it is better to have too many hidden units than too few.
With too few hidden units, the model might not have enough ﬂexibility to
capture the nonlinearities in the data; with too many hidden units, the
extra weights can be shrunk toward zero if appropriate regularization is
used. Typically the number of hidden units is somewhere in the range of
5 to 100, with the number increasing with the number of inputs and num-
ber of training cases. It is most common to put down a reasonably large
number of units and train them with regularization. Some researchers use
cross-validation to estimate the optimal number, but this seems unneces-
sary if cross-validation is used to estimate the regularization parameter.
Choice of the number of hidden layers is guided by background knowledge
and experimentation. Each layer extracts features of the input for regres-
sion or classiﬁcation. Use of multiple hidden layers allows construction of
hierarchical features at diﬀerent levels of resolution. An example of the
eﬀective use of multiple layers is given in Section 11.6.

11.5.5 Multiple Minima

The error function R(θ) is nonconvex, possessing many local minima. As a
result, the ﬁnal solution obtained is quite dependent on the choice of start-

11.6 Example: Simulated Data

401

ing weights. One must at least try a number of random starting conﬁgura-
tions, and choose the solution giving lowest (penalized) error. Probably a
better approach is to use the average predictions over the collection of net-
works as the ﬁnal prediction (Ripley, 1996). This is preferable to averaging
the weights, since the nonlinearity of the model implies that this averaged
solution could be quite poor. Another approach is via bagging, which aver-
ages the predictions of networks training from randomly perturbed versions
of the training data. This is described in Section 8.7.

11.6 Example: Simulated Data

We generated data from two additive error models Y = f (X) + ε:

Sum of sigmoids: Y = σ(aT

1 X) + σ(aT

2 X) + ε1;

Radial: Y =

φ(Xm) + ε2.

10

m=1
Y

Here X T = (X1, X2, . . . , Xp), each Xj being a standard Gaussian variate,
with p = 2 in the ﬁrst model, and p = 10 in the second.

For the sigmoid model, a1 = (3, 3), a2 = (3,

3); for the radial model,
−
t2/2). Both ε1 and ε2 are Gaussian errors, with

φ(t) = (1/2π)1/2 exp(
−
variance chosen so that the signal-to-noise ratio

Var(E(Y

X))

Var(Y

−

|
E(Y

X))

|

=

Var(f (X))
Var(ε)

(11.18)

−

is 4 in both models. We took a training sample of size 100 and a test sample
of size 10, 000. We ﬁt neural networks with weight decay and various num-
ˆf (X))2
bers of hidden units, and recorded the average test error ETest(Y
for each of 10 random starting weights. Only one training set was gen-
erated, but the results are typical for an “average” training set. The test
errors are shown in Figure 11.6. Note that the zero hidden unit model refers
to linear least squares regression. The neural network is perfectly suited to
the sum of sigmoids model, and the two-unit model does perform the best,
achieving an error close to the Bayes rate. (Recall that the Bayes rate for
regression with squared error is the error variance; in the ﬁgures, we report
test error relative to the Bayes error). Notice, however, that with more hid-
den units, overﬁtting quickly creeps in, and with some starting weights the
model does worse than the linear model (zero hidden unit) model. Even
with two hidden units, two of the ten starting weight conﬁgurations pro-
duced results no better than the linear model, conﬁrming the importance
of multiple starting values.

A radial function is in a sense the most diﬃcult for the neural net, as it is
spherically symmetric and with no preferred directions. We see in the right

402

Neural Networks

Sum of Sigmoids

Radial

r
o
r
r

E

t
s
e
T

0
.
3

5
.
2

0
.
2

5
.
1

0
.
1

r
o
r
r

E

t
s
e
T

0
3

5
2

0
2

5
1

0
1

5

0

0 1 2 3 4 5 6 7 8 9 10

0 1 2 3 4 5 6 7 8 9 10

Number of Hidden Units

Number of Hidden Units

FIGURE 11.6. Boxplots of test error, for simulated data example, relative to
the Bayes error (broken horizontal line). True function is a sum of two sigmoids
on the left, and a radial function is on the right. The test error is displayed for
10 diﬀerent starting weights, for a single hidden layer neural network with the
number of units as indicated.

panel of Figure 11.6 that it does poorly in this case, with the test error
staying well above the Bayes error (note the diﬀerent vertical scale from
the left panel). In fact, since a constant ﬁt (such as the sample average)
achieves a relative error of 5 (when the SNR is 4), we see that the neural
networks perform increasingly worse than the mean.

In this example we used a ﬁxed weight decay parameter of 0.0005, rep-
resenting a mild amount of regularization. The results in the left panel of
Figure 11.6 suggest that more regularization is needed with greater num-
bers of hidden units.

In Figure 11.7 we repeated the experiment for the sum of sigmoids model,
with no weight decay in the left panel, and stronger weight decay (λ = 0.1)
in the right panel. With no weight decay, overﬁtting becomes even more
severe for larger numbers of hidden units. The weight decay value λ = 0.1
produces good results for all numbers of hidden units, and there does not
appear to be overﬁtting as the number of units increase. Finally, Figure 11.8
shows the test error for a ten hidden unit network, varying the weight decay
parameter over a wide range. The value 0.1 is approximately optimal.

In summary, there are two free parameters to select: the weight decay λ
and number of hidden units M . As a learning strategy, one could ﬁx either
parameter at the value corresponding to the least constrained model, to
ensure that the model is rich enough, and use cross-validation to choose
the other parameter. Here the least constrained values are zero weight decay
and ten hidden units. Comparing the left panel of Figure 11.7 to Figure
11.8, we see that the test error is less sensitive to the value of the weight

 
 
11.6 Example: Simulated Data

403

No Weight Decay

Weight Decay=0.1

r
o
r
r

E

t
s
e
T

0
.
3

5
.
2

0
.
2

5
.
1

0
.
1

r
o
r
r

E

t
s
e
T

0
.
3

5
.
2

0
.
2

5
.
1

0
.
1

0 1 2 3 4 5 6 7 8 9 10

0 1 2 3 4 5 6 7 8 9 10

Number of Hidden Units

Number of Hidden Units

FIGURE 11.7. Boxplots of test error, for simulated data example, relative to the
Bayes error. True function is a sum of two sigmoids. The test error is displayed
for ten diﬀerent starting weights, for a single hidden layer neural network with
the number units as indicated. The two panels represent no weight decay (left)
and strong weight decay λ = 0.1 (right).

Sum of Sigmoids, 10 Hidden Unit Model

r
o
r
r

E

t
s
e
T

2
.
2

0
.
2

8
.
1

6
.
1

4
.
1

2
.
1

0
1

.

0.00

0.02

0.04

0.06

0.08

0.10

0.12

0.14

Weight Decay Parameter

FIGURE 11.8. Boxplots of test error, for simulated data example. True function
is a sum of two sigmoids. The test error is displayed for ten diﬀerent starting
weights, for a single hidden layer neural network with ten hidden units and weight
decay parameter value as indicated.

 
 
 
404

Neural Networks

FIGURE 11.9. Examples of training cases from ZIP code data. Each image is
a 16

16 8-bit grayscale representation of a handwritten digit.

×

decay parameter, and hence cross-validation of this parameter would be
preferred.

11.7 Example: ZIP Code Data

This example is a character recognition task: classiﬁcation of handwritten
numerals. This problem captured the attention of the machine learning and
neural network community for many years, and has remained a benchmark
problem in the ﬁeld. Figure 11.9 shows some examples of normalized hand-
written digits, automatically scanned from envelopes by the U.S. Postal
Service. The original scanned digits are binary and of diﬀerent sizes and
orientations; the images shown here have been deslanted and size normal-
16 grayscale images (Le Cun et al., 1990). These 256
ized, resulting in 16
pixel values are used as inputs to the neural network classiﬁer.

×

A black box neural network is not ideally suited to this pattern recogni-
tion task, partly because the pixel representation of the images lack certain
invariances (such as small rotations of the image). Consequently early at-
tempts with neural networks yielded misclassiﬁcation rates around 4.5%
on various examples of the problem. In this section we show some of the
pioneering eﬀorts to handcraft the neural network to overcome some these
deﬁciencies (Le Cun, 1989), which ultimately led to the state of the art in
neural network performance(Le Cun et al., 1998)1.

Although current digit datasets have tens of thousands of training and
test examples, the sample size here is deliberately modest in order to em-

1The ﬁgures and tables in this example were recreated from Le Cun (1989).

11.7 Example: ZIP Code Data

405

10

10

12

10

4x4

8x8

16x16

16x16

16x16

Net-1

Net-2

10

4x4

8x8x2

Net-3

Local Connectivity

10

4x4x4

8x8x2

16x16

16x16

Net-4

Shared Weights

Net-5

FIGURE 11.10. Architecture of the ﬁve networks used in the ZIP code example.

phasize the eﬀects. The examples were obtained by scanning some actual
hand-drawn digits, and then generating additional images by random hor-
izontal shifts. Details may be found in Le Cun (1989). There are 320 digits
in the training set, and 160 in the test set.

Five diﬀerent networks were ﬁt to the data:

Net-1: No hidden layer, equivalent to multinomial logistic regression.

Net-2: One hidden layer, 12 hidden units fully connected.

Net-3: Two hidden layers locally connected.

Net-4: Two hidden layers, locally connected with weight sharing.

Net-5: Two hidden layers, locally connected, two levels of weight sharing.

These are depicted in Figure 11.10. Net-1 for example has 256 inputs, one
each for the 16
16 input pixels, and ten output units for each of the digits
0–9. The predicted value ˆfk(x) represents the estimated probability that
an image x has digit class k, for k = 0, 1, 2, . . . , 9.

×

406

Neural Networks

a
t
a
D

t
s
e
T
n
o
t
c
e
r
r
o
C
%

100

90

80

70

60

Net-5

Net-4

Net-3

Net-2

Net-1

0

5

10

15

20

25

30

Training Epochs

FIGURE 11.11. Test performance curves, as a function of the number of train-
ing epochs, for the ﬁve networks of Table 11.1 applied to the ZIP code data.
(Le Cun, 1989)

The networks all have sigmoidal output units, and were all ﬁt with the
sum-of-squares error function. The ﬁrst network has no hidden layer, and
hence is nearly equivalent to a linear multinomial regression model (Exer-
cise 11.4). Net-2 is a single hidden layer network with 12 hidden units, of
the kind described above.

The training set error for all of the networks was 0%, since in all cases
there are more parameters than training observations. The evolution of the
test error during the training epochs is shown in Figure 11.11. The linear
network (Net-1) starts to overﬁt fairly quickly, while test performance of
the others level oﬀ at successively superior values.

The other three networks have additional features which demonstrate
the power and ﬂexibility of the neural network paradigm. They introduce
constraints on the network, natural for the problem at hand, which allow
for more complex connectivity but fewer parameters.

×

8 array), each unit takes inputs from a 3

Net-3 uses local connectivity: this means that each hidden unit is con-
nected to only a small patch of units in the layer below. In the ﬁrst hidden
layer (an 8
3 patch of the input
layer; for units in the ﬁrst hidden layer that are one unit apart, their recep-
tive ﬁelds overlap by one row or column, and hence are two pixels apart.
In the second hidden layer, inputs are from a 5
5 patch, and again units
that are one unit apart have receptive ﬁelds that are two units apart. The
weights for all other connections are set to zero. Local connectivity makes
each unit responsible for extracting local features from the layer below, and

×

×

 
 
 
 
11.7 Example: ZIP Code Data

407

TABLE 11.1. Test set performance of ﬁve diﬀerent neural networks on a hand-
written digit classiﬁcation example (Le Cun, 1989).

Network Architecture
Single layer network

Net-1:
Net-2: Two layer network
Net-3: Locally connected
Net-4: Constrained network 1
Net-5: Constrained network 2

Links Weights % Correct
80.0%
2570
2570
87.0%
3214
3214
88.5%
1226
1226
94.0%
1132
2266
98.4%
1060
5194

reduces considerably the total number of weights. With many more hidden
units than Net-2, Net-3 has fewer links and hence weights (1226 vs. 3214),
and achieves similar performance.

×

8 arrays, and each unit takes input from a 3

Net-4 and Net-5 have local connectivity with shared weights. All units
in a local feature map perform the same operation on diﬀerent parts of the
image, achieved by sharing the same weights. The ﬁrst hidden layer of Net-
4 has two 8
3 patch just like
8 feature map share the
in Net-3. However, each of the units in a single 8
same set of nine weights (but have their own bias parameter). This forces
the extracted features in diﬀerent parts of the image to be computed by
the same linear functional, and consequently these networks are sometimes
known as convolutional networks. The second hidden layer of Net-4 has
no weight sharing, and is the same as in Net-3. The gradient of the error
function R with respect to a shared weight is the sum of the gradients of
R with respect to each connection controlled by the weights in question.

×

×

×
×

Table 11.1 gives the number of links, the number of weights and the
optimal test performance for each of the networks. We see that Net-4 has
more links but fewer weights than Net-3, and superior test performance.
4 feature maps in the second hidden layer, each unit
Net-5 has four 4
5 local patch in the layer below. Weights are shared
connected to a 5
in each of these feature maps. We see that Net-5 does the best, having
errors of only 1.6%, compared to 13% for the “vanilla” network Net-2.
The clever design of network Net-5, motivated by the fact that features of
handwriting style should appear in more than one part of a digit, was the
result of many person years of experimentation. This and similar networks
gave better performance on ZIP code problems than any other learning
method at that time (early 1990s). This example also shows that neural
networks are not a fully automatic tool, as they are sometimes advertised.
As with all statistical models, subject matter knowledge can and should be
used to improve their performance.

This network was later outperformed by the tangent distance approach
(Simard et al., 1993) described in Section 13.3.3, which explicitly incorpo-
rates natural aﬃne invariances. At this point the digit recognition datasets
become test beds for every new learning procedure, and researchers worked

408

Neural Networks

hard to drive down the error rates. As of this writing, the best error rates on
a large database (60, 000 training, 10, 000 test observations), derived from
standard NIST2 databases, were reported to be the following: (Le Cun et
al., 1998):

•

•

•

•

1.1% for tangent distance with a 1-nearest neighbor classiﬁer (Sec-
tion 13.3.3);

0.8% for a degree-9 polynomial SVM (Section 12.3);

0.8% for LeNet-5, a more complex version of the convolutional net-
work described here;

0.7% for boosted LeNet-4. Boosting is described in Chapter 8. LeNet-
4 is a predecessor of LeNet-5.

Le Cun et al. (1998) report a much larger table of performance results, and
it is evident that many groups have been working very hard to bring these
test error rates down. They report a standard error of 0.1% on the error
estimates, which is based on a binomial average with N = 10, 000 and
p
0.01. This implies that error rates within 0.1—0.2% of one another
are statistically equivalent. Realistically the standard error is even higher,
since the test data has been implicitly used in the tuning of the various
procedures.

≈

11.8 Discussion

Both projection pursuit regression and neural networks take nonlinear func-
tions of linear combinations (“derived features”) of the inputs. This is a
powerful and very general approach for regression and classiﬁcation, and
has been shown to compete well with the best learning methods on many
problems.

These tools are especially eﬀective in problems with a high signal-to-noise
ratio and settings where prediction without interpretation is the goal. They
are less eﬀective for problems where the goal is to describe the physical pro-
cess that generated the data and the roles of individual inputs. Each input
enters into the model in many places, in a nonlinear fashion. Some authors
(Hinton, 1989) plot a diagram of the estimated weights into each hidden
unit, to try to understand the feature that each unit is extracting. This
is limited however by the lack of identiﬁability of the parameter vectors
αm, m = 1, . . . , M . Often there are solutions with αm spanning the same
linear space as the ones found during training, giving predicted values that

2The National Institute of Standards and Technology maintain large databases, in-

cluding handwritten character databases; http://www.nist.gov/srd/.

11.9 Bayesian Neural Nets and the NIPS 2003 Challenge

409

are roughly the same. Some authors suggest carrying out a principal com-
ponent analysis of these weights, to try to ﬁnd an interpretable solution. In
general, the diﬃculty of interpreting these models has limited their use in
ﬁelds like medicine, where interpretation of the model is very important.

There has been a great deal of research on the training of neural net-
works. Unlike methods like CART and MARS, neural networks are smooth
functions of real-valued parameters. This facilitates the development of
Bayesian inference for these models. The next sections discusses a success-
ful Bayesian implementation of neural networks.

11.9 Bayesian Neural Nets and the NIPS 2003

Challenge

A classiﬁcation competition was held in 2003, in which ﬁve labeled train-
ing datasets were provided to participants. It was organized for a Neural
Information Processing Systems (NIPS) workshop. Each of the data sets
constituted a two-class classiﬁcation problems, with diﬀerent sizes and from
a variety of domains (see Table 11.2). Feature measurements for a valida-
tion dataset were also available.

Participants developed and applied statistical learning procedures to
make predictions on the datasets, and could submit predictions to a web-
site on the validation set for a period of 12 weeks. With this feedback,
participants were then asked to submit predictions for a separate test set
and they received their results. Finally, the class labels for the validation
set were released and participants had one week to train their algorithms
on the combined training and validation sets, and submit their ﬁnal pre-
dictions to the competition website. A total of 75 groups participated, with
20 and 16 eventually making submissions on the validation and test sets,
respectively.

There was an emphasis on feature extraction in the competition. Arti-
ﬁcial “probes” were added to the data: these are noise features with dis-
tributions resembling the real features but independent of the class labels.
The percentage of probes that were added to each dataset, relative to the
total set of features, is shown on Table 11.2. Thus each learning algorithm
had to ﬁgure out a way of identifying the probes and downweighting or
eliminating them.

A number of metrics were used to evaluate the entries, including the
percentage correct on the test set, the area under the ROC curve, and a
combined score that compared each pair of classiﬁers head-to-head. The
results of the competition are very interesting and are detailed in Guyon et
al. (2006). The most notable result: the entries of Neal and Zhang (2006)
were the clear overall winners. In the ﬁnal competition they ﬁnished ﬁrst

410

Neural Networks

TABLE 11.2. NIPS 2003 challenge data sets. The column labeled p is the number
of features. For the Dorothea dataset the features are binary. Ntr, Nval and Nte
are the number of training, validation and test cases, respectively

Dataset

Domain

Feature
Type
Mass spectrometry Dense
Sparse
Text classiﬁcation
Sparse
Dense
Dense

Arcene
Dexter
Dorothea Drug discovery
Gisette
Madelon

Digit recognition
Artiﬁcial

p

10,000
20,000
100,000
5000
500

Percent Ntr
Probes
30
50
50
30
96

100
300
800
6000
2000

Nval Nte

100
300
350
1000
600

700
2000
800
6500
1800

in three of the ﬁve datasets, and were 5th and 7th on the remaining two
datasets.

In their winning entries, Neal and Zhang (2006) used a series of pre-
processing feature-selection steps, followed by Bayesian neural networks,
Dirichlet diﬀusion trees, and combinations of these methods. Here we focus
only on the Bayesian neural network approach, and try to discern which
aspects of their approach were important for its success. We rerun their
programs and compare the results to boosted neural networks and boosted
trees, and other related methods.

11.9.1 Bayes, Boosting and Bagging

Let us ﬁrst review brieﬂy the Bayesian approach to inference and its appli-
cation to neural networks. Given training data Xtr, ytr, we assume a sam-
pling model with parameters θ; Neal and Zhang (2006) use a two-hidden-
layer neural network, with output nodes the class probabilities Pr(Y
X, θ)
for the binary outcomes. Given a prior distribution Pr(θ), the posterior
distribution for the parameters is

|

Pr(θ

Pr(θ)Pr(ytr|
Pr(θ)Pr(ytr|
For a test case with features Xnew, the predictive distribution for the

Xtr, θ)
Xtr, θ)dθ

Xtr, ytr) =

(11.19)

R

|

label Ynew is

|

Z

Xnew, θ)Pr(θ

Pr(Ynew|

Xnew, Xtr, ytr) =

Xtr, ytr)dθ (11.20)

Pr(Ynew|
(c.f. equation 8.24). Since the integral in (11.20) is intractable, sophisticated
Markov Chain Monte Carlo (MCMC) methods are used to sample from the
Xnew, Xtr, ytr). A few hundred values θ are
posterior distribution Pr(Ynew|
generated and then a simple average of these values estimates the integral.
Neal and Zhang (2006) use diﬀuse Gaussian priors for all of the parame-
ters. The particular MCMC approach that was used is called hybrid Monte
Carlo, and may be important for the success of the method. It includes
an auxiliary momentum vector and implements Hamiltonian dynamics in
which the potential function is the target density. This is done to avoid

11.9 Bayesian Neural Nets and the NIPS 2003 Challenge

411

random walk behavior; the successive candidates move across the sample
space in larger steps. They tend to be less correlated and hence converge
to the target distribution more rapidly.

Neal and Zhang (2006) also tried diﬀerent forms of pre-processing of the

features:

1. univariate screening using t-tests, and

2. automatic relevance determination.

In the latter method (ARD), the weights (coeﬃcients) for the jth feature
to each of the ﬁrst hidden layer units all share a common prior variance
σ2
j , and prior mean zero. The posterior distributions for each variance σ2
j
are computed, and the features whose posterior variance concentrates on
small values are discarded.

There are thus three main features of this approach that could be im-

portant for its success:

(a) the feature selection and pre-processing,

(b) the neural network model, and

(c) the Bayesian inference for the model using MCMC.

According to Neal and Zhang (2006), feature screening in (a) is carried
out purely for computational eﬃciency; the MCMC procedure is slow with
a large number of features. There is no need to use feature selection to avoid
overﬁtting. The posterior average (11.20) takes care of this automatically.
We would like to understand the reasons for the success of the Bayesian
method. In our view, power of modern Bayesian methods does not lie in
their use as a formal inference procedure; most people would not believe
that the priors in a high-dimensional, complex neural network model are
actually correct. Rather the Bayesian/MCMC approach gives an eﬃcient
way of sampling the relevant parts of model space, and then averaging the
predictions for the high-probability models.

Bagging and boosting are non-Bayesian procedures that have some simi-
larity to MCMC in a Bayesian model. The Bayesian approach ﬁxes the data
and perturbs the parameters, according to current estimate of the poste-
rior distribution. Bagging perturbs the data in an i.i.d fashion and then
re-estimates the model to give a new set of model parameters. At the end,
a simple average of the model predictions from diﬀerent bagged samples is
computed. Boosting is similar to bagging, but ﬁts a model that is additive
in the models of each individual base learner, which are learned using non
i.i.d. samples. We can write all of these models in the form

ˆf (xnew) =

L

Xℓ=1

wℓE(Ynew|

xnew, ˆθℓ)

(11.21)

412

Neural Networks

In all cases the ˆθℓ are a large collection of model parameters. For the
Bayesian model the wℓ = 1/L, and the average estimates the posterior
mean (11.21) by sampling θℓ from the posterior distribution. For bagging,
wℓ = 1/L as well, and the ˆθℓ are the parameters reﬁt to bootstrap re-
samples of the training data. For boosting, the weights are all equal to
1, but the ˆθℓ are typically chosen in a nonrandom sequential fashion to
constantly improve the ﬁt.

11.9.2 Performance Comparisons

Based on the similarities above, we decided to compare Bayesian neural
networks to boosted trees, boosted neural networks, random forests and
bagged neural networks on the ﬁve datasets in Table 11.2. Bagging and
boosting of neural networks are not methods that we have previously used
in our work. We decided to try them here, because of the success of Bayesian
neural networks in this competition, and the good performance of bagging
and boosting with trees. We also felt that by bagging and boosting neural
nets, we could assess both the choice of model as well as the model search
strategy.

Here are the details of the learning methods that were compared:

Bayesian neural nets. The results here are taken from Neal and Zhang
(2006), using their Bayesian approach to ﬁtting neural networks. The
models had two hidden layers of 20 and 8 units. We re-ran some
networks for timing purposes only.

Boosted trees. We used the gbm package (version 1.5-7) in the R language.
Tree depth and shrinkage factors varied from dataset to dataset. We
consistently bagged 80% of the data at each boosting iteration (the
default is 50%). Shrinkage was between 0.001 and 0.1. Tree depth was
between 2 and 9.

Boosted neural networks. Since boosting is typically most eﬀective with
“weak” learners, we boosted a single hidden layer neural network with
two or four units, ﬁt with the nnet package (version 7.2-36) in R.

Random forests. We used the R package randomForest (version 4.5-16)

with default settings for the parameters.

Bagged neural networks. We used the same architecture as in the Bayesian
neural network above (two hidden layers of 20 and 8 units), ﬁt using
both Neal’s C language package “Flexible Bayesian Modeling” (2004-
11-10 release), and Matlab neural-net toolbox (version 5.1).

11.9 Bayesian Neural Nets and the NIPS 2003 Challenge

413

Univariate Screened Features

ARD Reduced Features

Bayesian neural nets
boosted trees 
boosted neural nets
random forests
bagged neural networks 

)

%

(

r
o
r
r

E

t
s
e
T

5
2

5
1

5

)

%

(

r
o
r
r

E

t
s
e
T

5
2

5
1

5

Arcene

Dexter

Dorothea

Gisette

Madelon

Arcene

Dexter

Dorothea

Gisette

Madelon

FIGURE 11.12. Performance of diﬀerent learning methods on ﬁve problems,
using both univariate screening of features (top panel) and a reduced feature set
from automatic relevance determination. The error bars at the top of each plot
have width equal to one standard error of the diﬀerence between two error rates.
On most of the problems several competitors are within this error bound.

This analysis was carried out by Nicholas Johnson, and full details may
be found in Johnson (2008)3. The results are shown in Figure 11.12 and
Table 11.3.

The ﬁgure and table show Bayesian, boosted and bagged neural networks,
boosted trees, and random forests, using both the screened and reduced
features sets. The error bars at the top of each plot indicate one standard
error of the diﬀerence between two error rates. Bayesian neural networks
again emerge as the winner, although for some datasets the diﬀerences
between the test error rates is not statistically signiﬁcant. Random forests
performs the best among the competitors using the selected feature set,
while the boosted neural networks perform best with the reduced feature
set, and nearly match the Bayesian neural net.

The superiority of boosted neural networks over boosted trees suggest
that the neural network model is better suited to these particular prob-
lems. Speciﬁcally, individual features might not be good predictors here

3We also thank Isabelle Guyon for help in preparing the results of this section.

 
 
 
 
414

Neural Networks

TABLE 11.3. Performance of diﬀerent methods. Values are average rank of test
error across the ﬁve problems (low is good), and mean computation time and
standard error of the mean, in minutes.

Method

Bayesian neural networks
Boosted trees
Boosted neural networks
Random forests
Bagged neural networks

Average
Rank

Screened Features
Average
Time
384(138)
3.03(2.5)
9.4(8.6)
1.9(1.7)
3.5(1.1)

1.5
3.4
3.8
2.7
3.6

ARD Reduced Features
Average
Rank

Average
Time
600(186)
34.1(32.4)
35.6(33.5)
11.2(9.3)
6.4(4.4)

1.6
4.0
2.2
3.2
4.0

and linear combinations of features work better. However the impressive
performance of random forests is at odds with this explanation, and came
as a surprise to us.

Since the reduced feature sets come from the Bayesian neural network
approach, only the methods that use the screened features are legitimate,
self-contained procedures. However, this does suggest that better methods
for internal feature selection might help the overall performance of boosted
neural networks.

The table also shows the approximate training time required for each

method. Here the non-Bayesian methods show a clear advantage.

Overall, the superior performance of Bayesian neural networks here may

be due to the fact that

(a) the neural network model is well suited to these ﬁve problems, and

(b) the MCMC approach provides an eﬃcient way of exploring the im-
portant part of the parameter space, and then averaging the resulting
models according to their quality.

The Bayesian approach works well for smoothly parametrized models like
neural nets; it is not yet clear that it works as well for non-smooth models
like trees.

11.10 Computational Considerations

With N observations, p predictors, M hidden units and L training epochs, a
neural network ﬁt typically requires O(N pM L) operations. There are many
packages available for ﬁtting neural networks, probably many more than
exist for mainstream statistical methods. Because the available software
varies widely in quality, and the learning problem for neural networks is
sensitive to issues such as input scaling, such software should be carefully
chosen and tested.

Exercises

415

Bibliographic Notes

Projection pursuit was proposed by Friedman and Tukey (1974), and spe-
cialized to regression by Friedman and Stuetzle (1981). Huber (1985) gives
a scholarly overview, and Roosen and Hastie (1994) present a formulation
using smoothing splines. The motivation for neural networks dates back
to McCulloch and Pitts (1943), Widrow and Hoﬀ (1960) (reprinted in An-
derson and Rosenfeld (1988)) and Rosenblatt (1962). Hebb (1949) heavily
inﬂuenced the development of learning algorithms. The resurgence of neural
networks in the mid 1980s was due to Werbos (1974), Parker (1985) and
Rumelhart et al. (1986), who proposed the back-propagation algorithm.
Today there are many books written on the topic, for a broad range of
audiences. For readers of this book, Hertz et al. (1991), Bishop (1995) and
Ripley (1996) may be the most informative. Bayesian learning for neural
networks is described in Neal (1996). The ZIP code example was taken from
Le Cun (1989); see also Le Cun et al. (1990) and Le Cun et al. (1998).

We do not discuss theoretical topics such as approximation properties of
neural networks, such as the work of Barron (1993), Girosi et al. (1995)
and Jones (1992). Some of these results are summarized by Ripley (1996).

Exercises

Ex. 11.1 Establish the exact correspondence between the projection pur-
suit regression model (11.1) and the neural network (11.5). In particular,
show that the single-layer regression network is equivalent to a PPR model
with gm(ωT
mx)), where ωm is the mth unit vector.
Establish a similar equivalence for a classiﬁcation network.

mx) = βmσ(α0m + sm(ωT

Ex. 11.2 Consider a neural network for a quantitative outcome as in (11.5),
using squared-error loss and identity output function gk(t) = t. Suppose
that the weights αm from the input to hidden layer are nearly zero. Show
that the resulting model is nearly linear in the inputs.

Ex. 11.3 Derive the forward and backward propagation equations for the
cross-entropy loss function.

Ex. 11.4 Consider a neural network for a K class outcome that uses cross-
entropy loss. If the network has no hidden layer, show that the model is
equivalent to the multinomial logistic model described in Chapter 4.

Ex. 11.5

(a) Write a program to ﬁt a single hidden layer neural network (ten hidden

units) via back-propagation and weight decay.

416

Neural Networks

(b) Apply it to 100 observations from the model

Y = σ(aT

1 X) + (aT

2 X)2 + 0.30

Z,

·

where σ is the sigmoid function, Z is standard normal, X T = (X1, X2),
each Xj being independent standard normal, and a1 = (3, 3), a2 =
(3,
3). Generate a test sample of size 1000, and plot the training and
test error curves as a function of the number of training epochs, for
diﬀerent values of the weight decay parameter. Discuss the overﬁtting
behavior in each case.

−

(c) Vary the number of hidden units in the network, from 1 up to 10, and
determine the minimum number needed to perform well for this task.

Ex. 11.6 Write a program to carry out projection pursuit regression, using
cubic smoothing splines with ﬁxed degrees of freedom. Fit it to the data
from the previous exercise, for various values of the smoothing parameter
and number of model terms. Find the minimum number of model terms
necessary for the model to perform well and compare this to the number
of hidden units from the previous exercise.

Ex. 11.7 Fit a neural network to the spam data of Section 9.1.2, and compare
the results to those for the additive model given in that chapter. Compare
both the classiﬁcation performance and interpretability of the ﬁnal model.

This is page 417
Printer: Opaque this

12
Support Vector Machines and
Flexible Discriminants

12.1

Introduction

In this chapter we describe generalizations of linear decision boundaries
for classiﬁcation. Optimal separating hyperplanes are introduced in Chap-
ter 4 for the case when two classes are linearly separable. Here we cover
extensions to the nonseparable case, where the classes overlap. These tech-
niques are then generalized to what is known as the support vector machine,
which produces nonlinear boundaries by constructing a linear boundary in
a large, transformed version of the feature space. The second set of methods
generalize Fisher’s linear discriminant analysis (LDA). The generalizations
include ﬂexible discriminant analysis which facilitates construction of non-
linear boundaries in a manner very similar to the support vector machines,
penalized discriminant analysis for problems such as signal and image clas-
siﬁcation where the large number of features are highly correlated, and
mixture discriminant analysis for irregularly shaped classes.

12.2 The Support Vector Classiﬁer

In Chapter 4 we discussed a technique for constructing an optimal separat-
ing hyperplane between two perfectly separated classes. We review this and
generalize to the nonseparable case, where the classes may not be separable
by a linear boundary.

418

12. Flexible Discriminants

xT β + β0 = 0

•

•

•

•
•
•

•

•

•

•

•

•
•

•

•

• •
•

M = 1
kβk

•

•

margin

M = 1
kβk

•

•
•
ξ∗
5
•

•
•
•

•

xT β + β0 = 0

•

ξ∗
4ξ∗
4ξ∗
4

3ξ∗
ξ∗
3
•
2ξ∗
2ξ∗
ξ∗
2

•
•
ξ∗
1ξ∗
1ξ∗
1

•

• •
•

•

•

•

•
•

•

•

M = 1
kβk

margin

M = 1
kβk

FIGURE 12.1. Support vector classiﬁers. The left panel shows the separable
case. The decision boundary is the solid line, while broken lines bound the shaded
maximal margin of width 2M = 2/
. The right panel shows the nonseparable
β
k
(overlap) case. The points labeled ξ∗
j are on the wrong side of their margin by
an amount ξ∗
j = M ξj; points on the correct side have ξ∗
j = 0. The margin is
ξ∗
j is the total
maximized subject to a total budget
distance of points on the wrong side of their margin.

constant. Hence

P

P

≤

ξi

k

Our training data consists of N pairs (x1, y1), (x2, y2), . . . , (xN , yN ), with
. Deﬁne a hyperplane by
1, 1
}

IRp and yi ∈ {−

xi ∈

x : f (x) = xT β + β0 = 0
,
}
{

(12.1)

where β is a unit vector:

β
k

k

= 1. A classiﬁcation rule induced by f (x) is

G(x) = sign[xT β + β0].

(12.2)

The geometry of hyperplanes is reviewed in Section 4.5, where we show that
f (x) in (12.1) gives the signed distance from a point x to the hyperplane
f (x) = xT β +β0 = 0. Since the classes are separable, we can ﬁnd a function
f (x) = xT β + β0 with yif (xi) > 0
i. Hence we are able to ﬁnd the
hyperplane that creates the biggest margin between the training points for
1 (see Figure 12.1). The optimization problem
class 1 and

∀

−

max
β,β0,kβk=1

M

subject to yi(xT

i β + β0)

M, i = 1, . . . , N,

≥

(12.3)

captures this concept. The band in the ﬁgure is M units away from the
hyperplane on either side, and hence 2M units wide. It is called the margin.
We showed that this problem can be more conveniently rephrased as

min
β,β0 k
subject to yi(xT

k
i β + β0)

β

1, i = 1, . . . , N,

≥

(12.4)

12.2 The Support Vector Classiﬁer

419

where we have dropped the norm constraint on β. Note that M = 1/
.
β
k
k
Expression (12.4) is the usual way of writing the support vector criterion
for separated data. This is a convex optimization problem (quadratic cri-
terion, linear inequality constraints), and the solution is characterized in
Section 4.5.2.

Suppose now that the classes overlap in feature space. One way to deal
with the overlap is to still maximize M , but allow for some points to be on
the wrong side of the margin. Deﬁne the slack variables ξ = (ξ1, ξ2, . . . , ξN ).
There are two natural ways to modify the constraint in (12.3):

yi(xT

i β + β0)

yi(xT

i β + β0)

M

ξi,

−

M (1

ξi),

−

≥
or

≥

(12.5)

(12.6)

N

0,

P

i=1 ξi ≤

constant. The two choices lead to diﬀerent solutions.
i, ξi ≥
∀
The ﬁrst choice seems more natural, since it measures overlap in actual
distance from the margin; the second choice measures the overlap in relative
distance, which changes with the width of the margin M . However, the ﬁrst
choice results in a nonconvex optimization problem, while the second is
convex; thus (12.6) leads to the “standard” support vector classiﬁer, which
we use from here on.

−

M (1

Here is the idea of the formulation. The value ξi in the constraint yi(xT

i β+
ξi) is the proportional amount by which the prediction
β0)
≥
f (xi) = xT
i β +β0 is on the wrong side of its margin. Hence by bounding the
sum
ξi, we bound the total proportional amount by which predictions
fall on the wrong side of their margin. Misclassiﬁcations occur when ξi > 1,
P
ξi at a value K say, bounds the total number of training
so bounding
misclassiﬁcations at K.

As in (4.48) in Section 4.5.2, we can drop the norm constraint on β,
, and write (12.4) in the equivalent form
k

β
deﬁne M = 1/
k

P

k

min

β
k

subject to

yi(xT
ξi ≥
This is the usual way the support vector classiﬁer is deﬁned for the non-
separable case. However we ﬁnd confusing the presence of the ﬁxed scale
“1” in the constraint yi(xT
ξi, and prefer to start with (12.6).
1
The right panel of Figure 12.1 illustrates this overlapping case.

i β + β0)
≥
ξi ≤
0,

1
i,
ξi ∀
constant.

i β + β0)

(12.7)

P

(

−

−

≥

By the nature of the criterion (12.7), we see that points well inside their
class boundary do not play a big role in shaping the boundary. This seems
like an attractive property, and one that diﬀerentiates it from linear dis-
criminant analysis (Section 4.3). In LDA, the decision boundary is deter-
mined by the covariance of the class distributions and the positions of the
class centroids. We will see in Section 12.3.3 that logistic regression is more
similar to the support vector classiﬁer in this regard.

420

12. Flexible Discriminants

12.2.1 Computing the Support Vector Classiﬁer

The problem (12.7) is quadratic with linear inequality constraints, hence it
is a convex optimization problem. We describe a quadratic programming
solution using Lagrange multipliers. Computationally it is convenient to
re-express (12.7) in the equivalent form

min
β,β0

1
2 k

β

2 + C
k

N

ξi

subject to ξi ≥

i=1
X
0, yi(xT

i β + β0)

(12.8)

1

i,

ξi ∀

−

≥

where the “cost” parameter C replaces the constant in (12.7); the separable
case corresponds to C =

.

The Lagrange (primal) function is

∞

LP =

1
2 k

β

2 + C
k

N

N

ξi −

i=1
X

i=1
X

αi[yi(xT

i β + β0)

(1

−

−

ξi)]

−

µiξi, (12.9)

N

i=1
X

which we minimize w.r.t β, β0 and ξi. Setting the respective derivatives to
zero, we get

N

β =

αiyixi,

i=1
X
N

0 =

αiyi,

αi = C

i=1
X
−

µi,

i,

∀

(12.10)

(12.11)

(12.12)

i. By substituting
as well as the positivity constraints αi, µi, ξi ≥
(12.10)–(12.12) into (12.9), we obtain the Lagrangian (Wolfe) dual objec-
tive function

∀

0

LD =

αi −

1
2

N

i=1
X

N

N

i=1
X

Xi′=1

αiαi′ yiyi′xT

i xi′ ,

(12.13)

which gives a lower bound on the objective function (12.8) for any feasible
N
point. We maximize LD subject to 0
i=1 αiyi = 0. In
addition to (12.10)–(12.12), the Karush–Kuhn–Tucker conditions include
the constraints

αi ≤

C and

P

≤

αi[yi(xT

i β + β0)

(1

−

−

yi(xT

i β + β0)

(1

ξi)] = 0,
µiξi = 0,
0,

ξi)

(12.14)
(12.15)

(12.16)

−
for i = 1, . . . , N . Together these equations (12.10)–(12.16) uniquely char-
acterize the solution to the primal and dual problem.

−

≥

12.2 The Support Vector Classiﬁer

421

From (12.10) we see that the solution for β has the form

ˆβ =

N

i=1
X

ˆαiyixi,

(12.17)

with nonzero coeﬃcients ˆαi only for those observations i for which the
constraints in (12.16) are exactly met (due to (12.14)). These observations
are called the support vectors, since ˆβ is represented in terms of them
alone. Among these support points, some will lie on the edge of the margin
( ˆξi = 0), and hence from (12.15) and (12.12) will be characterized by
0 < ˆαi < C; the remainder ( ˆξi > 0) have ˆαi = C. From (12.14) we can
see that any of these margin points (0 < ˆαi, ˆξi = 0) can be used to solve
for β0, and we typically use an average of all the solutions for numerical
stability.

Maximizing the dual (12.13) is a simpler convex quadratic programming
problem than the primal (12.9), and can be solved with standard techniques
(Murray et al., 1981, for example).

Given the solutions ˆβ0 and ˆβ, the decision function can be written as

ˆG(x) = sign[ ˆf (x)]

= sign[xT ˆβ + ˆβ0].

(12.18)

The tuning parameter of this procedure is the cost parameter C.

12.2.2 Mixture Example (Continued)

Figure 12.2 shows the support vector boundary for the mixture example
of Figure 2.5 on page 21, with two overlapping classes, for two diﬀerent
values of the cost parameter C. The classiﬁers are rather similar in their
performance. Points on the wrong side of the boundary are support vectors.
In addition, points on the correct side of the boundary but close to it (in
the margin), are also support vectors. The margin is larger for C = 0.01
than it is for C = 10, 000. Hence larger values of C focus attention more
on (correctly classiﬁed) points near the decision boundary, while smaller
values involve data further away. Either way, misclassiﬁed points are given
weight, no matter how far away. In this example the procedure is not very
sensitive to choices of C, because of the rigidity of a linear boundary.

The optimal value for C can be estimated by cross-validation, as dis-
cussed in Chapter 7. Interestingly, the leave-one-out cross-validation error
can be bounded above by the proportion of support points in the data. The
reason is that leaving out an observation that is not a support vector will
not change the solution. Hence these observations, being classiﬁed correctly
by the original boundary, will be classiﬁed correctly in the cross-validation
process. However this bound tends to be too high, and not generally useful
for choosing C (62% and 85%, respectively, in our examples).

422

12. Flexible Discriminants

o

o

o

o

o

o

o

o

o

o
o

o
o

o
o
o
o

o
o
o
o
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o o
•
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . ..
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
o
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
oo
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
oo
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
.. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.270
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.288
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o
o

o
o
o
o

o
o

o
o
o

o
o

o
o
o

o
o

o

o

o

o

o

o

o

o

o

o

C = 10000

o

o

o

o

o

o

o

o

o
o

o
o

o
o

o
o
o
o
o

o
o
o
•
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .. ..
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
oo
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
oo
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
.. .. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.26
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.30
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.21

o
o
o
o
o

o
o
o
o

o
o

o
o
o

o
o

o
o
o

o
o

o

o

o

o

o

o

o

o

o

C = 0.01

FIGURE 12.2. The linear support vector boundary for the mixture data exam-
ple with two overlapping classes, for two diﬀerent values of C. The broken lines
indicate the margins, where f (x) =
1. The support points (αi > 0) are all the
points on the wrong side of their margin. The black solid dots are those support
points falling exactly on the margin (ξi = 0, αi > 0). In the upper panel 62% of
the observations are support points, while in the lower panel 85% are. The broken
purple curve in the background is the Bayes decision boundary.

±

12.3 Support Vector Machines and Kernels

423

12.3 Support Vector Machines and Kernels

The support vector classiﬁer described so far ﬁnds linear boundaries in the
input feature space. As with other linear methods, we can make the pro-
cedure more ﬂexible by enlarging the feature space using basis expansions
such as polynomials or splines (Chapter 5). Generally linear boundaries
in the enlarged space achieve better training-class separation, and trans-
late to nonlinear boundaries in the original space. Once the basis functions
hm(x), m = 1, . . . , M are selected, the procedure is the same as before. We
ﬁt the SV classiﬁer using input features h(xi) = (h1(xi), h2(xi), . . . , hM (xi)),
i = 1, . . . , N , and produce the (nonlinear) function ˆf (x) = h(x)T ˆβ + ˆβ0.
The classiﬁer is ˆG(x) = sign( ˆf (x)) as before.

The support vector machine classiﬁer is an extension of this idea, where
the dimension of the enlarged space is allowed to get very large, inﬁnite
in some cases. It might seem that the computations would become pro-
hibitive. It would also seem that with suﬃcient basis functions, the data
would be separable, and overﬁtting would occur. We ﬁrst show how the
SVM technology deals with these issues. We then see that in fact the SVM
classiﬁer is solving a function-ﬁtting problem using a particular criterion
and form of regularization, and is part of a much bigger class of problems
that includes the smoothing splines of Chapter 5. The reader may wish
to consult Section 5.8, which provides background material and overlaps
somewhat with the next two sections.

12.3.1 Computing the SVM for Classiﬁcation

We can represent the optimization problem (12.9) and its solution in a
special way that only involves the input features via inner products. We do
this directly for the transformed feature vectors h(xi). We then see that for
particular choices of h, these inner products can be computed very cheaply.

The Lagrange dual function (12.13) has the form

LD =

αi −

1
2

N

i=1
X

N

N

i=1
X

Xi′=1

αiαi′ yiyi′

h

h(xi), h(xi′ )

.

i

(12.19)

From (12.10) we see that the solution function f (x) can be written

f (x) = h(x)T β + β0
N

=

i=1
X

αiyih

h(x), h(xi)

+ β0.

i

(12.20)

As before, given αi, β0 can be determined by solving yif (xi) = 1 in (12.20)
for any (or all) xi for which 0 < αi < C.

424

12. Flexible Discriminants

So both (12.19) and (12.20) involve h(x) only through inner products. In
fact, we need not specify the transformation h(x) at all, but require only
knowledge of the kernel function

K(x, x′) =

h(x), h(x′)

h

i

(12.21)

that computes inner products in the transformed space. K should be a
symmetric positive (semi-) deﬁnite function; see Section 5.8.1.

Three popular choices for K in the SVM literature are

dth-Degree polynomial: K(x, x′) = (1 +
Radial basis: K(x, x′) = exp(
x
γ
k
−
x, x′
Neural network: K(x, x′) = tanh(κ1h

x, x′

)d,
x′

−

h

i

i

2),
k
+ κ2).

(12.22)

Consider for example a feature space with two inputs X1 and X2, and a
polynomial kernel of degree 2. Then

K(X, X ′) = (1 +

X, X ′
h
= (1 + X1X ′
= 1 + 2X1X ′

)2
1 + X2X ′
2)2
2 + (X1X ′
1 + 2X2X ′

i

1)2 + (X2X ′

2)2 + 2X1X ′

1X2X ′
2.
(12.23)

Then M = 6, and if we choose h1(X) = 1, h2(X) = √2X1, h3(X) =
2 , and h6(X) = √2X1X2, then K(X, X ′) =

1 , h5(X) = X 2

. From (12.20) we see that the solution can be written

√2X2, h4(X) = X 2
h(X), h(X ′)

h

i

N

ˆf (x) =

ˆαiyiK(x, xi) + ˆβ0.

(12.24)

i=1
X

The role of the parameter C is clearer in an enlarged feature space,
since perfect separation is often achievable there. A large value of C will
discourage any positive ξi, and lead to an overﬁt wiggly boundary in the
original feature space; a small value of C will encourage a small value of
, which in turn causes f (x) and hence the boundary to be smoother.
β
k
k
Figure 12.3 show two nonlinear support vector machines applied to the
mixture example of Chapter 2. The regularization parameter was chosen
in both cases to achieve good test error. The radial basis kernel produces
a boundary quite similar to the Bayes optimal boundary for this example;
compare Figure 2.5.

In the early literature on support vectors, there were claims that the
kernel property of the support vector machine is unique to it and allows
one to ﬁnesse the curse of dimensionality. Neither of these claims is true,
and we go into both of these issues in the next three subsections.

12.3 Support Vector Machines and Kernels

425

SVM - Degree-4 Polynomial in Feature Space

•
o

o

o

o

o

o

•
o

o
o

o
o

o
o
o
o

•
o
o
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
•
o
•
•
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
o
•
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . .
o
o
o
•
o
o
o
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
oo
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
oo
o
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
o
o
•
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . .
. . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . .
. . . . . .
oo
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . .
. . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . .
o
•
o
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . .
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . .
o
o
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
o
o
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
•
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.180
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.245
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

• •

o
o

o
o

•
o
o

o

o

o

o

o

SVM - Radial Kernel in Feature Space

•
o

o

o

o

o

o

o

•
o

•
o

o
o

o
o
•
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . .
•
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . .
•
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . .
•
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
•
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
•
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
•
o
o
•
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
•
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o
o
•
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . .
•
o
o
o
oo
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
•
•
o
o
oo
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
•
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . .
o
o
o
o
. . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . .
. . . . . . . . . .
oo
•
o
o
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
.
. . . . . . . . .
o
o
o
•
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
.
. . . . . . . . .
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
.
. . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. .
. . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . .
. . . . . . .
o
•
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. .
. . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . .
. . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . .
. . . . .
o
o
o
o
o
•
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . .
. . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . .
. . . .
o
o
. . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . .
o
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
. . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.160
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.218
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o
o

o
o

o
•
o

o
o
o

•
o
o

•
o

•
o

•
o

o

o

o
o
o
•
o
•
o

FIGURE 12.3. Two nonlinear SVMs for the mixture data. The upper plot uses
a 4th degree polynomial kernel, the lower a radial basis kernel (with γ = 1). In
each case C was tuned to approximately achieve the best test error performance,
and C = 1 worked well in both cases. The radial basis kernel performs the best
(close to Bayes optimal), as might be expected given the data arise from mixtures
of Gaussians. The broken purple curve in the background is the Bayes decision
boundary.

Hinge Loss
Binomial Deviance
Squared Error
Class Huber

426

12. Flexible Discriminants

s
s
o
L

0
.
3

5
.
2

0
.
2

5
.
1

0
.
1

5
.
0

0
.
0

−3

−2

−1

1

2

3

0

yf

FIGURE 12.4. The support vector loss function (hinge loss), compared to the
negative log-likelihood loss (binomial deviance) for logistic regression, squared-er-
ror loss, and a “Huberized” version of the squared hinge loss. All are shown as a
function of yf rather than f , because of the symmetry between the y = +1 and
y =
1 case. The deviance and Huber have the same asymptotes as the SVM
loss, but are rounded in the interior. All are scaled to have the limiting left-tail
slope of

1.

−

−

12.3.2 The SVM as a Penalization Method

With f (x) = h(x)T β + β0, consider the optimization problem

min
β0, β

N

i=1
X

[1

−

yif (xi)]+ +

λ
2 k

β

2
k

(12.25)

where the subscript “+” indicates positive part. This has the form loss +
penalty, which is a familiar paradigm in function estimation. It is easy to
show (Exercise 12.1) that the solution to (12.25), with λ = 1/C, is the
same as that for (12.8).

Examination of the “hinge” loss function L(y, f ) = [1

yf ]+ shows that
it is reasonable for two-class classiﬁcation, when compared to other more
traditional loss functions. Figure 12.4 compares it to the log-likelihood loss
for logistic regression, as well as squared-error loss and a variant thereof.
The (negative) log-likelihood or binomial deviance has similar tails as the
SVM loss, giving zero penalty to points well inside their margin, and a

−

12.3 Support Vector Machines and Kernels

427

TABLE 12.1. The population minimizers for the diﬀerent loss functions in Fig-
ure 12.4. Logistic regression uses the binomial log-likelihood or deviance. Linear
discriminant analysis (Exercise 4.2) uses squared-error loss. The SVM hinge loss
estimates the mode of the posterior class probabilities, whereas the others estimate
a linear transformation of these probabilities.

Loss Function

L[y, f (x)]

Minimizing Function

Binomial
Deviance

SVM Hinge
Loss

Squared
Error

“Huberised”
Square
Hinge Loss

log[1 + e−yf (x)]

f (x) = log

Pr(Y = +1
Pr(Y = -1

x)
|
x)
|

[1

−

yf (x)]+

f (x) = sign[Pr(Y = +1

x)

|

−

1
2 ]

[y

−

f (x)]2 = [1

yf (x)]2

−

f (x) = 2Pr(Y = +1

4yf (x),

yf (x) < -1

f (x) = 2Pr(Y = +1

−
[1

yf (x)]2

+ otherwise

−

x)

−

x)

−

|

|

1

1

linear penalty to points on the wrong side and far away. Squared-error, on
the other hand gives a quadratic penalty, and points well inside their own
margin have a strong inﬂuence on the model as well. The squared hinge
+ is like the quadratic, except it is zero for points
loss L(y, f ) = [1
inside their margin. It still rises quadratically in the left tail, and will be
less robust than hinge or deviance to misclassiﬁed observations. Recently
Rosset and Zhu (2007) proposed a “Huberized” version of the squared hinge
loss, which converts smoothly to a linear loss at yf =

yf ]2

−

1.

We can characterize these loss functions in terms of what they are es-
timating at the population level. We consider minimizing EL(Y, f (X)).
Table 12.1 summarizes the results. Whereas the hinge loss estimates the
classiﬁer G(x) itself, all the others estimate a transformation of the class
posterior probabilities. The “Huberized” square hinge loss shares attractive
properties of logistic regression (smooth loss function, estimates probabili-
ties), as well as the SVM hinge loss (support points).

Formulation (12.25) casts the SVM as a regularized function estimation
problem, where the coeﬃcients of the linear expansion f (x) = β0 + h(x)T β
are shrunk toward zero (excluding the constant). If h(x) represents a hierar-
chical basis having some ordered structure (such as ordered in roughness),

−

428

12. Flexible Discriminants

then the uniform shrinkage makes more sense if the rougher elements hj in
the vector h have smaller norm.

All the loss-functions in Table 12.1 except squared-error are so called
“margin maximizing loss-functions” (Rosset et al., 2004b). This means that
if the data are separable, then the limit of ˆβλ in (12.25) as λ
0 deﬁnes
the optimal separating hyperplane1.

→

12.3.3 Function Estimation and Reproducing Kernels

Here we describe SVMs in terms of function estimation in reproducing
kernel Hilbert spaces, where the kernel property abounds. This material is
discussed in some detail in Section 5.8. This provides another view of the
support vector classiﬁer, and helps to clarify how it works.

Suppose the basis h arises from the (possibly ﬁnite) eigen-expansion of

a positive deﬁnite kernel K,

∞

K(x, x′) =

φm(x)φm(x′)δm

(12.26)

m=1
X

and hm(x) = √δmφm(x). Then with θm = √δmβm, we can write (12.25)
as

N

∞

min
β0, θ

1
i=1"
X

−

yi(β0 +

θmφm(xi))

m=1
X

+

λ
2

#+

∞

m=1
X

θ2
m
δm

.

(12.27)

Now (12.27) is identical in form to (5.49) on page 169 in Section 5.8, and
the theory of reproducing kernel Hilbert spaces described there guarantees
a ﬁnite-dimensional solution of the form

N

f (x) = β0 +

αiK(x, xi).

(12.28)

i=1
X
In particular we see there an equivalent version of the optimization crite-
rion (12.19) [Equation (5.67) in Section 5.8.2; see also Wahba et al. (2000)],

min
β0,α

N

i=1
X

(1

−

yif (xi))+ +

λ
2

αT Kα,

(12.29)

where K is the N
features (Exercise 12.2).

×

N matrix of kernel evaluations for all pairs of training

These models are quite general, and include, for example, the entire fam-
ily of smoothing splines, additive and interaction spline models discussed

1For logistic regression with separable data, ˆβλ diverges, but ˆβλ/|| ˆβλ converges to

the optimal separating direction.

12.3 Support Vector Machines and Kernels

429

in Chapters 5 and 9, and in more detail in Wahba (1990) and Hastie and
Tibshirani (1990). They can be expressed more generally as

min
f ∈H

N

i=1
X

[1

−

yif (xi)]+ + λJ(f ),

(12.30)

H

is the structured space of functions, and J(f ) an appropriate reg-
where
is the space of additive
ularizer on that space. For example, suppose
H
2dxj. Then the
f ′′
functions f (x) =
}
{
solution to (12.30) is an additive cubic spline, and has a kernel representa-
P
p
j=1 Kj(xj, x′
tion (12.28) with K(x, x′) =
j). Each of the Kj is the kernel
appropriate for the univariate smoothing spline in xj (Wahba, 1990).

p
j=1 fj(xj), and J(f ) =

j(xj)

P

R

j

Conversely this discussion also shows that, for example, any of the kernels
described in (12.22) above can be used with any convex loss function, and
will also lead to a ﬁnite-dimensional representation of the form (12.28).
Figure 12.5 uses the same kernel functions as in Figure 12.3, except using
the binomial log-likelihood as a loss function2. The ﬁtted function is hence
an estimate of the log-odds,

P

ˆf (x) = log

ˆPr(Y = +1
|
ˆPr(Y =
1
|
N

−

x)

x)

= ˆβ0 +

ˆαiK(x, xi),

(12.31)

i=1
X

or conversely we get an estimate of the class probabilities

ˆPr(Y = +1
|

x) =

1
1 + e− ˆβ0−PN
i=1 ˆαiK(x,xi)

.

(12.32)

The ﬁtted models are quite similar in shape and performance. Examples
and more details are given in Section 5.8.

It does happen that for SVMs, a sizable fraction of the N values of αi
can be zero (the nonsupport points). In the two examples in Figure 12.3,
these fractions are 42% and 45%, respectively. This is a consequence of the
piecewise linear nature of the ﬁrst part of the criterion (12.25). The lower
the class overlap (on the training data), the greater this fraction will be.
Reducing λ will generally reduce the overlap (allowing a more ﬂexible f ).
A small number of support points means that ˆf (x) can be evaluated more
quickly, which is important at lookup time. Of course, reducing the overlap
too much can lead to poor generalization.

2Ji Zhu assisted in the preparation of these examples.

430

12. Flexible Discriminants

LR - Degree-4 Polynomial in Feature Space

o

o

o

o

o

o

o

o

o
o

o
o

o
o

o
o
o
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o o
. . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
o
o
o
oo
. . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
oo
o
. . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . .
. . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . .
. . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . .
. . .
o
o
o
o
. . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
oo
o
o
o
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . .
. . .
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. .
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.190
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.263
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o

o
o

o
o
o

o
o

o
o

o

o

o

o

o

o

o

o

LR - Radial Kernel in Feature Space

o

o

o

o

o

o

o

o

o
o

o
o

o
o
o
o

. . . . . . . . . . . . . .
. . . . . . . . . . . . .

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
.
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . .
.
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . .
.
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . .
. . .
.
. . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . .
.
. . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . .
. .
. . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . .
. .
. . . . . . . . . .
. . . . . . . . . . . .
oo
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . .
. .
. . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . .
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . .
. . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . .
. . .
. . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . .
. . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . .
o
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . .
. . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . .
o
o
o
o
. . . . . . . . . .
. . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . .
. . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . .
. . . . . . . . . . . . . . .
. . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
. . . . . . .
. . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
o
o
o
o
. . . . . .
. . . . . . . . . . . . .
.
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.150
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.221
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o
o

o
o
o
o

o
o
oo

o
o

o
o
o

o
o

o
o

o
o

o

o

o

o

o

o

FIGURE 12.5. The logistic regression versions of the SVM models in Fig-
ure 12.3, using the identical kernels and hence penalties, but the log-likelihood
loss instead of the SVM loss function. The two broken contours correspond to
posterior probabilities of 0.75 and 0.25 for the +1 class (or vice versa). The bro-
ken purple curve in the background is the Bayes decision boundary.

12.3 Support Vector Machines and Kernels

431

TABLE 12.2. Skin of the orange: Shown are mean (standard error of the mean)
of the test error over 50 simulations. BRUTO ﬁts an additive spline model adap-
tively, while MARS ﬁts a low-order interaction model adaptively.

Test Error (SE)

Method
SV Classiﬁer
SVM/poly 2
SVM/poly 5
SVM/poly 10

1
2
3
4
5 BRUTO
6 MARS
Bayes

No Noise Features
0.450 (0.003)
0.078 (0.003)
0.180 (0.004)
0.230 (0.003)
0.084 (0.003)
0.156 (0.004)
0.029

Six Noise Features
0.472 (0.003)
0.152 (0.004)
0.370 (0.004)
0.434 (0.002)
0.090 (0.003)
0.173 (0.005)
0.029

12.3.4 SVMs and the Curse of Dimensionality

In this section, we address the question of whether SVMs have some edge
on the curse of dimensionality. Notice that in expression (12.23) we are not
allowed a fully general inner product in the space of powers and products.
For example, all terms of the form 2XjX ′
j are given equal weight, and the
kernel cannot adapt itself to concentrate on subspaces. If the number of
features p were large, but the class separation occurred only in the linear
subspace spanned by say X1 and X2, this kernel would not easily ﬁnd the
structure and would suﬀer from having many dimensions to search over.
One would have to build knowledge about the subspace into the kernel;
that is, tell it to ignore all but the ﬁrst two inputs. If such knowledge were
available a priori, much of statistical learning would be made much easier.
A major goal of adaptive methods is to discover such structure.

We support these statements with an illustrative example. We generated
100 observations in each of two classes. The ﬁrst class has four standard
normal independent features X1, X2, X3, X4. The second class also has four
standard normal independent features, but conditioned on 9
16.
This is a relatively easy problem. As a second harder problem, we aug-
mented the features with an additional six standard Gaussian noise fea-
tures. Hence the second class almost completely surrounds the ﬁrst, like the
skin surrounding the orange, in a four-dimensional subspace. The Bayes er-
ror rate for this problem is 0.029 (irrespective of dimension). We generated
1000 test observations to compare diﬀerent procedures. The average test
errors over 50 simulations, with and without noise features, are shown in
Table 12.2.

j ≤

X 2

P

≤

Line 1 uses the support vector classiﬁer in the original feature space.
Lines 2–4 refer to the support vector machine with a 2-, 5- and 10-dimension-
al polynomial kernel. For all support vector procedures, we chose the cost
parameter C to minimize the test error, to be as fair as possible to the

432

12. Flexible Discriminants

Test Error Curves − SVM with Radial Kernel

γ = 5

γ = 1

γ = 0.5

γ = 0.1

r
o
r
r

E

t
s
e
T

5
3

.

0

0
3
0

.

5
2
0

.

0
2
0

.

1e−01

1e+01

1e+03

1e−01

1e+01

1e+03

1e−01

1e+01

1e+03

1e−01

1e+01

1e+03

C

FIGURE 12.6. Test-error curves as a function of the cost parameter C for the
radial-kernel SVM classiﬁer on the mixture data. At the top of each plot is the
2. The optimal
scale parameter γ for the radial kernel: Kγ(x, y) = exp
value for C depends quite strongly on the scale of the kernel. The Bayes error
rate is indicated by the broken horizontal lines.

−

−

x

||

||

γ

y

method. Line 5 ﬁts an additive spline model to the (
1, +1) response by
least squares, using the BRUTO algorithm for additive models, described
in Hastie and Tibshirani (1990). Line 6 uses MARS (multivariate adaptive
regression splines) allowing interaction of all orders, as described in Chap-
ter 9; as such it is comparable with the SVM/poly 10. Both BRUTO and
MARS have the ability to ignore redundant variables. Test error was not
used to choose the smoothing parameters in either of lines 5 or 6.

−

In the original feature space, a hyperplane cannot separate the classes,
and the support vector classiﬁer (line 1) does poorly. The polynomial sup-
port vector machine makes a substantial improvement in test error rate,
but is adversely aﬀected by the six noise features. It is also very sensitive to
the choice of kernel: the second degree polynomial kernel (line 2) does best,
since the true decision boundary is a second-degree polynomial. However,
higher-degree polynomial kernels (lines 3 and 4) do much worse. BRUTO
performs well, since the boundary is additive. BRUTO and MARS adapt
well: their performance does not deteriorate much in the presence of noise.

12.3.5 A Path Algorithm for the SVM Classiﬁer

The regularization parameter for the SVM classiﬁer is the cost parameter
C, or its inverse λ in (12.25). Common usage is to set C high, leading often
to somewhat overﬁt classiﬁers.

Figure 12.6 shows the test error on the mixture data as a function of
C, using diﬀerent radial-kernel parameters γ. When γ = 5 (narrow peaked
kernels), the heaviest regularization (small C) is called for. With γ = 1

 
12.3 Support Vector Machines and Kernels

433

9

11

8

7

f (x) = +1

f (x) = 0

5

10

3

12

6

f (x) = −1

2

1

5
.
1

0
.
1

5
.
0

0
.
0

5
.
0
−

0
.
1
−

1/||β||

λ

0
1

8

6

4

2

0

−0.5

0.0

0.5

1.0

1.5

4

2.0

0.0

0.2

9
4

8
1

11

6

2
7

10
3

12
5

1.0

0.4

0.8

0.6
αi(λ)

= 2

0.587. Two blue points

FIGURE 12.7. A simple example illustrates the SVM path algorithm. (left
panel:) This plot illustrates the state of the model at λ = 0.5. The ‘‘ + 1”
1” blue. λ = 1/2, and the width of the soft margin
points are orange, the “
are misclassiﬁed, while the two or-
β
is 2/
||
ange points
are correctly classiﬁed, but on the wrong side of their margin
f (x) = +1; each of these has yif (xi) < 1. The three square shaped points
}
are exactly on their margins. (right panel:) This plot shows the piecewise linear
proﬁles αi(λ). The horizontal broken line at λ = 1/2 indicates the state of the αi
for the model in the left plot.

×
10, 12

2, 6, 7

3, 5

−

||

{

}

{

}

{

(the value used in Figure 12.3), an intermediate value of C is required.
Clearly in situations such as these, we need to determine a good choice
for C, perhaps by cross-validation. Here we describe a path algorithm (in
the spirit of Section 3.8) for eﬃciently ﬁtting the entire sequence of SVM
models obtained by varying C.

It is convenient to use the loss+penalty formulation (12.25), along with

Figure 12.4. This leads to a solution for β at a given value of λ:

βλ =

1
λ

N

i=1
X

αiyixi.

(12.33)

The αi are again Lagrange multipliers, but in this case they all lie in [0, 1].
Figure 12.7 illustrates the setup. It can be shown that the KKT optimal-
ity conditions imply that the labeled points (xi, yi) fall into three distinct
groups:

434

12. Flexible Discriminants

•

•

•

Observations correctly classiﬁed and outside their margins. They have
yif (xi) > 1, and Lagrange multipliers αi = 0. Examples are the
orange points 8, 9 and 11, and the blue points 1 and 4.

Observations sitting on their margins with yif (xi) = 1, with Lagrange
[0, 1]. Examples are the orange 7 and the blue 2 and
multipliers αi ∈
8.

Observations inside their margins have yif (xi) < 1, with αi = 1.
Examples are the blue 3 and 5, and the orange 10 and 12.

||

||

βλ||

The idea for the path algorithm is as follows. Initially λ is large, the
is wide, and all points are inside their margin and have
margin 1/
βλ||
αi = 1. As λ decreases, 1/
decreases, and the margin gets narrower.
Some points will move from inside their margins to outside their margins,
and their αi will change from 1 to 0. By continuity of the αi(λ), these points
will linger on the margin during this transition. From (12.33) we see that
the points with αi = 1 make ﬁxed contributions to β(λ), and those with
αi = 0 make no contribution. So all that changes as λ decreases are the
[0, 1] of those (small number) of points on the margin. Since all these
αi ∈
points have yif (xi) = 1, this results in a small set of linear equations that
prescribe how αi(λ) and hence βλ changes during these transitions. This
results in piecewise linear paths for each of the αi(λ). The breaks occur
when points cross the margin. Figure 12.7 (right panel) shows the αi(λ)
proﬁles for the small example in the left panel.

Although we have described this for linear SVMs, exactly the same idea

works for nonlinear models, in which (12.33) is replaced by

fλ(x) =

1
λ

N

i=1
X

αiyiK(x, xi).

(12.34)

Details can be found in Hastie et al. (2004). An R package svmpath is
available on CRAN for ﬁtting these models.

12.3.6 Support Vector Machines for Regression

In this section we show how SVMs can be adapted for regression with a
quantitative response, in ways that inherit some of the properties of the
SVM classiﬁer. We ﬁrst discuss the linear regression model

f (x) = xT β + β0,

(12.35)

and then handle nonlinear generalizations. To estimate β, we consider min-
imization of

H(β, β0) =

N

i=1
X

V (yi −

f (xi)) +

λ
2 k

β

2,
k

(12.36)

)
r
(
ǫ
V

4

3

2

1

0

1
-

12.3 Support Vector Machines and Kernels

435

)
r
(
H
V

2
1

0
1

8

6

4

2

0

ǫ
−

-2

-4

ǫ

0
r

2

4

c
−

-2

-4

c

2

4

0
r

FIGURE 12.8. The left panel shows the ǫ-insensitive error function used by the
support vector regression machine. The right panel shows the error function used
in Huber’s robust regression (blue curve). Beyond
, the function changes from
quadratic to linear.

c

|

|

where

Vǫ(r) =

0
r

|

(

ǫ,

| −

r

if
< ǫ,
|
otherwise.

|

(12.37)

This is an “ǫ-insensitive” error measure, ignoring errors of size less than
ǫ (left panel of Figure 12.8). There is a rough analogy with the support
vector classiﬁcation setup, where points on the correct side of the deci-
sion boundary and far away from it, are ignored in the optimization. In
regression, these “low error” points are the ones with small residuals.

It is interesting to contrast this with error measures used in robust re-
gression in statistics. The most popular, due to Huber (1964), has the form

VH (r) =

r2/2
r
c
(

|

| −

c2/2,

c,

| ≤
> c,

if

|

r

|
r
|

(12.38)

shown in the right panel of Figure 12.8. This function reduces from quadratic
to linear the contributions of observations with absolute residual greater
than a prechosen constant c. This makes the ﬁtting less sensitive to out-
liers. The support vector error measure (12.37) also has linear tails (beyond
ǫ), but in addition it ﬂattens the contributions of those cases with small
residuals.

If ˆβ, ˆβ0 are the minimizers of H, the solution function can be shown to

have the form

ˆβ =

ˆf (x) =

N

i=1
X
N

i=1
X

(ˆα∗

i −

ˆαi)xi,

(ˆα∗

i −

ˆαi)

x, xii

h

+ β0,

(12.39)

(12.40)

436

12. Flexible Discriminants

where ˆαi, ˆα∗

i are positive and solve the quadratic programming problem

N

ǫ

(α∗

i + αi)

N

−

min
αi,α∗
i

i=1
X

i=1
X
subject to the constraints

yi(α∗

i −

αi) +

1
2

N

(α∗

i −

Xi,i′=1

αi)(α∗
i′

αi′ )

h

−

xi, xi′

i

αi, α∗

i ≤

1/λ,

0

≤
N

αi) = 0,

(12.41)

(α∗

i −
αiα∗

i=1
X

i = 0.

i −

Due to the nature of these constraints, typically only a subset of the solution
values (ˆα∗
ˆαi) are nonzero, and the associated data values are called the
support vectors. As was the case in the classiﬁcation setting, the solution
. Thus
depends on the input values only through the inner products
we can generalize the methods to richer spaces by deﬁning an appropriate
inner product, for example, one of those deﬁned in (12.22).

xi, xi′

i

h

Note that there are parameters, ǫ and λ, associated with the criterion
(12.36). These seem to play diﬀerent roles. ǫ is a parameter of the loss
function Vǫ, just like c is for VH . Note that both Vǫ and VH depend on the
scale of y and hence r. If we scale our response (and hence use VH (r/σ) and
Vǫ(r/σ) instead), then we might consider using preset values for c and ǫ (the
value c = 1.345 achieves 95% eﬃciency for the Gaussian). The quantity λ
is a more traditional regularization parameter, and can be estimated for
example by cross-validation.

12.3.7 Regression and Kernels

As discussed in Section 12.3.3, this kernel property is not unique to sup-
port vector machines. Suppose we consider approximation of the regression
function in terms of a set of basis functions

hm(x)
{

, m = 1, 2, . . . , M :
}

M

f (x) =

βmhm(x) + β0.

(12.42)

To estimate β and β0 we minimize

m=1
X

N

H(β, β0) =

i=1
X

V (yi −

f (xi)) +

λ
2

β2
m

(12.43)

X

for some general error measure V (r). For any choice of V (r), the solution
ˆf (x) =

ˆβmhm(x) + ˆβ0 has the form

P

ˆf (x) =

N

i=1
X

ˆaiK(x, xi)

(12.44)

12.3 Support Vector Machines and Kernels

437

M
with K(x, y) =
m=1 hm(x)hm(y). Notice that this has the same form
as both the radial basis function expansion and a regularization estimate,
discussed in Chapters 5 and 6.

P

For concreteness, let’s work out the case V (r) = r2. Let H be the N

M
basis matrix with imth element hm(xi), and suppose that M > N is large.
For simplicity we assume that β0 = 0, or that the constant is absorbed in
h; see Exercise 12.3 for an alternative.

×

We estimate β by minimizing the penalized least squares criterion

H(β) = (y

Hβ)T (y

Hβ) + λ

β
k

2.
k

−

−

The solution is

with ˆβ determined by

ˆy = H ˆβ

HT (y

−

−

H ˆβ) + λ ˆβ = 0.

(12.45)

(12.46)

(12.47)

From this it appears that we need to evaluate the M
M matrix of inner
products in the transformed space. However, we can premultiply by H to
give

×

H ˆβ = (HHT + λI)−1HHT y.

(12.48)

×

N matrix HHT consists of inner products between pairs of obser-
The N
vations i, i′; that is, the evaluation of an inner product kernel
}i,i′ =
K(xi, xi′ ). It is easy to show (12.44) directly in this case, that the predicted
values at an arbitrary x satisfy

HHT
{

ˆf (x) = h(x)T ˆβ

N

=

ˆαiK(x, xi),

(12.49)

i=1
X
where ˆα = (HHT + λI)−1y. As in the support vector machine, we need not
specify or evaluate the large set of functions h1(x), h2(x), . . . , hM (x). Only
the inner product kernel K(xi, xi′ ) need be evaluated, at the N training
points for each i, i′ and at points x for predictions there. Careful choice
of hm (such as the eigenfunctions of particular, easy-to-evaluate kernels
K) means, for example, that HHT can be computed at a cost of N 2/2
evaluations of K, rather than the direct cost N 2M .

Note, however, that this property depends on the choice of squared norm
,

2 in the penalty. It does not hold, for example, for the L1 norm
k

β
k
which may lead to a superior model.

β

|

|

438

12. Flexible Discriminants

12.3.8 Discussion

The support vector machine can be extended to multiclass problems, es-
sentially by solving many two-class problems. A classiﬁer is built for each
pair of classes, and the ﬁnal classiﬁer is the one that dominates the most
(Kressel, 1999; Friedman, 1996; Hastie and Tibshirani, 1998). Alternatively,
one could use the multinomial loss function along with a suitable kernel,
as in Section 12.3.3. SVMs have applications in many other supervised
and unsupervised learning problems. At the time of this writing, empirical
evidence suggests that it performs well in many real learning problems.

Finally, we mention the connection of the support vector machine and
structural risk minimization (7.9). Suppose the training points (or their
basis expansion) are contained in a sphere of radius R, and let G(x) =
sign[f (x)] = sign[βT x + β0] as in (12.2). Then one can show that the class
of functions

has VC-dimension h satisfying

G(x),
{

β
k

k ≤

A
}

R2A2.

h

≤

(12.50)

A, then with

If f (x) separates the training data, optimally for
probability at least 1

η over training sets (Vapnik, 1996, page 139):

k ≤

β
k

−
Error Test ≤

4

h[log (2N/h) + 1]

N

log (η/4)

.

−

(12.51)

The support vector classiﬁer was one of the ﬁrst practical learning pro-
cedures for which useful bounds on the VC dimension could be obtained,
and hence the SRM program could be carried out. However in the deriva-
tion, balls are put around the data points—a process that depends on the
observed values of the features. Hence in a strict sense, the VC complexity
of the class is not ﬁxed a priori, before seeing the features.

The regularization parameter C controls an upper bound on the VC
dimension of the classiﬁer. Following the SRM paradigm, we could choose C
by minimizing the upper bound on the test error, given in (12.51). However,
it is not clear that this has any advantage over the use of cross-validation
for choice of C.

12.4 Generalizing Linear Discriminant Analysis

In Section 4.3 we discussed linear discriminant analysis (LDA), a funda-
mental tool for classiﬁcation. For the remainder of this chapter we discuss
a class of techniques that produce better classiﬁers than LDA by directly
generalizing LDA.

Some of the virtues of LDA are as follows:

•

It is a simple prototype classiﬁer. A new observation is classiﬁed to the
class with closest centroid. A slight twist is that distance is measured
in the Mahalanobis metric, using a pooled covariance estimate.

12.4 Generalizing Linear Discriminant Analysis

439

•

•

•

•

LDA is the estimated Bayes classiﬁer if the observations are multi-
variate Gaussian in each class, with a common covariance matrix.
Since this assumption is unlikely to be true, this might not seem to
be much of a virtue.

The decision boundaries created by LDA are linear, leading to deci-
sion rules that are simple to describe and implement.

LDA provides natural low-dimensional views of the data. For exam-
ple, Figure 12.12 is an informative two-dimensional view of data in
256 dimensions with ten classes.

Often LDA produces the best classiﬁcation results, because of its
simplicity and low variance. LDA was among the top three classiﬁers
for 7 of the 22 datasets studied in the STATLOG project (Michie et
al., 1994)3.

Unfortunately the simplicity of LDA causes it to fail in a number of situa-
tions as well:

•

•

•

Often linear decision boundaries do not adequately separate the classes.
When N is large, it is possible to estimate more complex decision
boundaries. Quadratic discriminant analysis (QDA) is often useful
here, and allows for quadratic decision boundaries. More generally
we would like to be able to model irregular decision boundaries.

The aforementioned shortcoming of LDA can often be paraphrased
by saying that a single prototype per class is insuﬃcient. LDA uses
a single prototype (class centroid) plus a common covariance matrix
to describe the spread of the data in each class. In many situations,
several prototypes are more appropriate.

At the other end of the spectrum, we may have way too many (corre-
lated) predictors, for example, in the case of digitized analogue signals
and images. In this case LDA uses too many parameters, which are
estimated with high variance, and its performance suﬀers. In cases
such as this we need to restrict or regularize LDA even further.

In the remainder of this chapter we describe a class of techniques that
attend to all these issues by generalizing the LDA model. This is achieved
largely by three diﬀerent ideas.

The ﬁrst idea is to recast the LDA problem as a linear regression problem.
Many techniques exist for generalizing linear regression to more ﬂexible,
nonparametric forms of regression. This in turn leads to more ﬂexible forms
of discriminant analysis, which we call FDA. In most cases of interest, the

3This study predated the emergence of SVMs.

440

12. Flexible Discriminants

regression procedures can be seen to identify an enlarged set of predictors
via basis expansions. FDA amounts to LDA in this enlarged space, the
same paradigm used in SVMs.

In the case of too many predictors, such as the pixels of a digitized image,
we do not want to expand the set: it is already too large. The second idea is
to ﬁt an LDA model, but penalize its coeﬃcients to be smooth or otherwise
coherent in the spatial domain, that is, as an image. We call this procedure
penalized discriminant analysis or PDA. With FDA itself, the expanded
basis set is often so large that regularization is also required (again as in
SVMs). Both of these can be achieved via a suitably regularized regression
in the context of the FDA model.

The third idea is to model each class by a mixture of two or more Gaus-
sians with diﬀerent centroids, but with every component Gaussian, both
within and between classes, sharing the same covariance matrix. This allows
for more complex decision boundaries, and allows for subspace reduction
as in LDA. We call this extension mixture discriminant analysis or MDA.
All three of these generalizations use a common framework by exploiting

their connection with LDA.

12.5 Flexible Discriminant Analysis

In this section we describe a method for performing LDA using linear re-
gression on derived responses. This in turn leads to nonparametric and ﬂex-
ible alternatives to LDA. As in Chapter 4, we assume we have observations
with a quantitative response G falling into one of K classes
,
1, . . . , K
}
{
IR1 is a function that
each having measured features X. Suppose θ :
assigns scores to the classes, such that the transformed class labels are op-
timally predicted by linear regression on X: If our training sample has the
form (gi, xi), i = 1, 2, . . . , N , then we solve

G 7→

=

G

min
β,θ

N

i=1
X

(cid:0)

θ(gi)

−

xT
i β

2

,

(12.52)

(cid:1)

with restrictions on θ to avoid a trivial solution (mean zero and unit vari-
ance over the training data). This produces a one-dimensional separation
between the classes.

More generally, we can ﬁnd up to L

1 sets of independent scorings
for the class labels, θ1, θ2, . . . , θL, and L corresponding linear maps ηℓ(X) =
X T βℓ, ℓ = 1, . . . , L, chosen to be optimal for multiple regression in IRp. The
scores θℓ(g) and the maps βℓ are chosen to minimize the average squared
residual,

K

≤

−

ASR =

1
N

L

N

Xℓ=1 "

i=1
X

(cid:0)

θℓ(gi)

xT
i βℓ

−

2

.

#

(cid:1)

(12.53)

12.5 Flexible Discriminant Analysis

441

The set of scores are assumed to be mutually orthogonal and normalized
with respect to an appropriate inner product to prevent trivial zero
solutions.

Why are we going down this road? It can be shown that the sequence
of discriminant (canonical) vectors νℓ derived in Section 4.3.3 are identical
to the sequence βℓ up to a constant (Mardia et al., 1979; Hastie et al.,
1995). Moreover, the Mahalanobis distance of a test point x to the kth
class centroid ˆµk is given by

K−1

δJ (x, ˆµk) =

wℓ(ˆηℓ(x)

Xℓ=1

ℓ )2 + D(x),
¯ηk

−

(12.54)

where ¯ηk
ℓ is the mean of the ˆηℓ(xi) in the kth class, and D(x) does not
depend on k. Here wℓ are coordinate weights that are deﬁned in terms of
the mean squared residual r2

ℓ of the ℓth optimally scored ﬁt

wℓ =

1

−

.

r2
ℓ )

r2
ℓ (1

(12.55)

In Section 4.3.2 we saw that these canonical distances are all that is needed
for classiﬁcation in the Gaussian setup, with equal covariances in each class.
To summarize:

LDA can be performed by a sequence of linear regressions, fol-
lowed by classiﬁcation to the closest class centroid in the space
of ﬁts. The analogy applies both to the reduced rank version,
or the full rank case when L = K

1.

−

The real power of this result is in the generalizations that it invites. We
can replace the linear regression ﬁts ηℓ(x) = xT βℓ by far more ﬂexible,
nonparametric ﬁts, and by analogy achieve a more ﬂexible classiﬁer than
LDA. We have in mind generalized additive ﬁts, spline functions, MARS
models and the like. In this more general form the regression problems are
deﬁned via the criterion

ASR(

θℓ, ηℓ}
{

L
ℓ=1) =

1
N

L

N

Xℓ=1 "

i=1
X

(θℓ(gi)

−

ηℓ(xi))2 + λJ(ηℓ)

(12.56)

,

#

where J is a regularizer appropriate for some forms of nonparametric regres-
sion, such as smoothing splines, additive splines and lower-order ANOVA
spline models. Also included are the classes of functions and associated
penalties generated by kernels, as in Section 12.3.3.

Before we describe the computations involved in this generalization, let
us consider a very simple example. Suppose we use degree-2 polynomial
regression for each ηℓ. The decision boundaries implied by the (12.54) will
be quadratic surfaces, since each of the ﬁtted functions is quadratic, and as

442

12. Flexible Discriminants

2

0

2
-

o

o

o

o

o

o

o

o
o
o
o

o

o
o
o
o
o
o
o
o
o

o

o

o
o

o
o o
o
o
o

o
o
o
o

o
o
oo
o

o

o

o

o

o
o

o

o
o
o

o

o

o

o

o
o o

o

o

o

o

o

o

o
o

o
o

o
o
o

o
o

o

o

o

o

o

o

o

o
o
o
o
o
o
o
o
o

o

o

o

o

o

o

o

o

o

o

o

o

0

2

-2

FIGURE 12.9. The data consist of 50 points generated from each of N (0, I) and
N (0, 9
4 I). The solid black ellipse is the decision boundary found by FDA using
degree-two polynomial regression. The dashed purple circle is the Bayes decision
boundary.

in LDA their squares cancel out when comparing distances. We could have
achieved identical quadratic boundaries in a more conventional way, by
augmenting our original predictors with their squares and cross-products.
In the enlarged space one performs an LDA, and the linear boundaries in
the enlarged space map down to quadratic boundaries in the original space.
A classic example is a pair of multivariate Gaussians centered at the origin,
one having covariance matrix I, and the other cI for c > 1; Figure 12.9
2(c−1) , which
illustrates. The Bayes decision boundary is the sphere
is a linear boundary in the enlarged space.

= pc log c

x

k

k

×

Many nonparametric regression procedures operate by generating a basis
expansion of derived variables, and then performing a linear regression in
the enlarged space. The MARS procedure (Chapter 9) is exactly of this
form. Smoothing splines and additive spline models generate an extremely
large basis set (N
p basis functions for additive splines), but then perform
a penalized regression ﬁt in the enlarged space. SVMs do as well; see also
the kernel-based regression example in Section 12.3.7. FDA in this case can
be shown to perform a penalized linear discriminant analysis in the enlarged
space. We elaborate in Section 12.6. Linear boundaries in the enlarged space
map down to nonlinear boundaries in the reduced space. This is exactly the
same paradigm that is used with support vector machines (Section 12.3).
We illustrate FDA on the speech recognition example used in Chapter
4.), with K = 11 classes and p = 10 predictors. The classes correspond to

12.5 Flexible Discriminant Analysis

443

Linear Discriminant Analysis

Flexible Discriminant Analysis -- Bruto

i

a
t
a
D
g
n
n
a
r
T
r
o
f

i

2

i

e
t
a
n
d
r
o
o
C

oooooo

oooooo

ooooo

oooooo
o

ooooo
o
oooooo
o
oooo
o
oo
oooo
o
o
o
o
ooo
o
o
oo
oooo
o
oooo
oo
oo
o
ooooo
o
o
o
o
oo
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o

o

o

ooo
o

oooo
o
o
oooooo
oooooo
o oooo
oo
oooooo
o
ooooo
o
o
o
o
oo
ooo
ooo
o
o o
oo
o o
o o
ooo
o
o
o
o
o
o
oo
oo
o
oooo
oooooo
ooo
o
o
o
o
o
oo
o
o o
oo
o
o
o
o o
o
o
o
o
o
o o o
o
o oo
o
o
o
oo
o
o
o
oo
oo o
o
o
o
ooo oo
o
o
o
oo
o
oooo
o
o
o
o
o
o
o
o oo
o
o
o
oo
oo o
o
o
o
o
o
ooo
ooo
oo
oo
o
o
o
oo
oo
o
oo
oo
o oo
o
o
oooooo
oo
o
o
o
o
o
o
oo o
o
ooo
o
ooo
o
oo
o
oooo
o
o
o
o
o
o
o
oo
o
o o
o
ooo
o
o
o o o
o
o
o
o
ooo
o
o
o
o
o
ooo
o
o
o o
oooo
o
o
o
oo
ooo
o o
ooo
o
o
o
o
ooo
o
o ooo
o
o
o oo
o
o
o
oo o
o
o
o
o
o
o
oo o

o oo

oooooo

o

o

o

o

oooooo
o
o
ooooo

oo
o
o
o
o
o
o
oooo
oo

oo
oooo

oo o
o

oo
ooo o

o

o
o

o o

o
o
ooooo
o
o
o o
oo
oo
oooo
ooo
ooo
o o oo oo
o
o
o

o

o

o

o
o

o

o

i

a
t
a
D
g
n
n
a
r
T
r
o
f

i

2

i

e
t
a
n
d
r
o
o
C

oo
o
o
oooo
o
o
o
oo
o
oo
o
o
ooo

oo
o

o
o o
o
o
o
o
ooooo
oooooo
o
o
o
o
o
o

ooo
o
oo
o o
oo
o
o
o
o
oo
o
oo
o
o
o
ooo
oo
o
o
o
o
o
o
o
o
o
o
ooo o
oo
o o o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
ooooo
o
o
ooo
o o
o
o
o
o
oooo o
o
ooo
o
o
o
o oo
o
o
o
o
ooo
oo
o
o
o
oooo
oo
o
o
o
o
oo
o
ooooo
oo o
o
o
o
oo oo
o
ooo
o
o
o
o
oo
ooooo
o
oo
o
oooo
oo
o
o
o
oo o
o
o
oooooo
o
ooo
o
o
o
o
o
o
oooo
o
oo
o
o
oo oo
oo
o
o
o
oooo
o
ooooo
o
o
oo
o
oooo
ooo
o
ooooo
o
o oo
o
oo
o
o
o o
o
o
ooo
oo
o
oooooo
o
oo
o
o
o
o
oo
ooo
oooo
o
oo
o
oo
ooo
o
o
ooo
o
o
o
o
ooo
o
oo
o
o
oo
oo
oo
ooo
o
o
o
o
o
o
o
o
o
oo
o
oo
oo
o
oo
o
oo
ooo
o
o
o
oo
o
o
o
o
oo
o
oooooo
ooooo
o
o
oooo
o
o
o oo
o
o
o
o o
o
o
o
ooo
o
oooo o
o
o
ooooo
o
o
o
oooooo
oo
oo
o
oooo
o
oo
o
oooooo
o
o

o

o

o

o

o

oooo

oo
ooo
o

o
oooo
o
oo oo
o
o
o
o o
ooo
o
o
oooooo
o
oo
o
o
o
ooooo o
o
oo
o
o
o
oo
o

Coordinate 1 for Training Data

Coordinate 1 for Training Data

FIGURE 12.10. The left plot shows the ﬁrst two LDA canonical variates for
the vowel training data. The right plot shows the corresponding projection when
FDA/BRUTO is used to ﬁt the model; plotted are the ﬁtted regression functions
ˆη1(xi) and ˆη2(xi). Notice the improved separation. The colors represent the eleven
diﬀerent vowel sounds.

11 vowel sounds, each contained in 11 diﬀerent words. Here are the words,
preceded by the symbols that represent them:

Vowel Word Vowel Word Vowel Word Vowel Word
hoard
i:
who’d
E
a:

hod
I
A
hood
heard Y

heed
head
hard

hid
had
hud

O
U
3:

C:
u:

Each of eight speakers spoke each word six times in the training set, and
likewise seven speakers in the test set. The ten predictors are derived from
the digitized speech in a rather complicated way, but standard in the speech
recognition world. There are thus 528 training observations, and 462 test
observations. Figure 12.10 shows two-dimensional projections produced by
LDA and FDA. The FDA model used adaptive additive-spline regression
functions to model the ηℓ(x), and the points plotted in the right plot have
coordinates ˆη1(xi) and ˆη2(xi). The routine used in S-PLUS is called bruto,
hence the heading on the plot and in Table 12.3. We see that ﬂexible model-
ing has helped to separate the classes in this case. Table 12.3 shows training
and test error rates for a number of classiﬁcation techniques. FDA/MARS
refers to Friedman’s multivariate adaptive regression splines; degree = 2
means pairwise products are permitted. Notice that for FDA/MARS, the
best classiﬁcation results are obtained in a reduced-rank subspace.

 
 
 
 
 
 
 
 
444

12. Flexible Discriminants

TABLE 12.3. Vowel recognition data performance results. The results for neural
networks are the best among a much larger set, taken from a neural network
archive. The notation FDA/BRUTO refers to the regression method used with
FDA.

Technique

(1) LDA

Softmax

Single-layer perceptron

(2) QDA
(3) CART
(4) CART (linear combination splits)
(5)
(6) Multi-layer perceptron (88 hidden units)
(7) Gaussian node network (528 hidden units)
(8) Nearest neighbor
(9) FDA/BRUTO
Softmax

(10) FDA/MARS (degree = 1)

Best reduced dimension (=2)
Softmax

(11) FDA/MARS (degree = 2)

Best reduced dimension (=6)
Softmax

Error Rates
Training Test

0.32
0.48
0.01
0.05
0.05

0.06
0.11
0.09
0.18
0.14
0.02
0.13
0.10

0.56
0.67
0.53
0.56
0.54
0.67
0.49
0.45
0.44
0.44
0.50
0.45
0.42
0.48
0.42
0.39
0.50

12.5.1 Computing the FDA Estimates

The computations for the FDA coordinates can be simpliﬁed in many im-
portant cases, in particular when the nonparametric regression procedure
can be represented as a linear operator. We will denote this operator by
Sλ; that is, ˆy = Sλy, where y is the vector of responses and ˆy the vector
of ﬁts. Additive splines have this property, if the smoothing parameters are
ﬁxed, as does MARS once the basis functions are selected. The subscript λ
denotes the entire set of smoothing parameters. In this case optimal scoring
is equivalent to a canonical correlation problem, and the solution can be
computed by a single eigen-decomposition. This is pursued in Exercise 12.6,
and the resulting algorithm is presented here.

We create an N

K indicator response matrix Y from the responses gi,
such that yik = 1 if gi = k, otherwise yik = 0. For a ﬁve-class problem Y
might look like the following:

×

12.5 Flexible Discriminant Analysis

445

g1 = 2
g2 = 1
g3 = 1
g4 = 5
g5 = 4
...
gN = 3














1
0
0
0
0

C1 C2 C3 C4 C5
0
0
0
0
0
1
0
0
1
1
0
0
0
0
0
...
1

0
0
0
0
1

0

0

0

0














Here are the computational steps:

1. Multivariate nonparametric regression. Fit a multiresponse, adaptive
nonparametric regression of Y on X, giving ﬁtted values ˆY. Let Sλ
be the linear operator that ﬁts the ﬁnal chosen model, and η∗(x) be
the vector of ﬁtted regression functions.

2. Optimal scores. Compute the eigen-decomposition of YT ˆY = YT SλY,
where the eigenvectors Θ are normalized: ΘT DπΘ = I. Here Dπ =
YT Y/N is a diagonal matrix of the estimated class prior
probabilities.

3. Update the model from step 1 using the optimal scores: η(x) = ΘT η∗(x).

The ﬁrst of the K functions in η(x) is the constant function— a trivial
solution; the remaining K
1 functions are the discriminant functions. The
constant function, along with the normalization, causes all the remaining
functions to be centered.

−

Again Sλ can correspond to any regression method. When Sλ = HX , the
linear regression projection operator, then FDA is linear discriminant anal-
ysis. The software that we reference in the Computational Considerations
section on page 455 makes good use of this modularity; the fda function
has a method= argument that allows one to supply any regression function,
as long as it follows some natural conventions. The regression functions
we provide allow for polynomial regression, adaptive additive models and
MARS. They all eﬃciently handle multiple responses, so step (1) is a single
call to a regression routine. The eigen-decomposition in step (2) simulta-
neously computes all the optimal scoring functions.

In Section 4.2 we discussed the pitfalls of using linear regression on an
indicator response matrix as a method for classiﬁcation. In particular, se-
vere masking can occur with three or more classes. FDA uses the ﬁts from
such a regression in step (1), but then transforms them further to produce
useful discriminant functions that are devoid of these pitfalls. Exercise 12.9
takes another view of this phenomenon.

446

12. Flexible Discriminants

12.6 Penalized Discriminant Analysis

Although FDA is motivated by generalizing optimal scoring, it can also be
viewed directly as a form of regularized discriminant analysis. Suppose the
regression procedure used in FDA amounts to a linear regression onto a
basis expansion h(X), with a quadratic penalty on the coeﬃcients:

ASR(

θℓ, βℓ}
{

L
ℓ=1) =

1
N

L

N

Xℓ=1 "

i=1
X

(θℓ(gi)

−

hT (xi)βℓ)2 + λβT

ℓ Ωβℓ

. (12.57)

#

The choice of Ω depends on the problem. If ηℓ(x) = h(x)βℓ is an expansion
on spline basis functions, Ω might constrain ηℓ to be smooth over IRp. In
the case of additive splines, there are N spline basis functions for each
coordinate, resulting in a total of N p basis functions in h(x); Ω in this case
is N p

N p and block diagonal.

The steps in FDA can then be viewed as a generalized form of LDA,

×

which we call penalized discriminant analysis, or PDA:

Enlarge the set of predictors X via a basis expansion h(X).

Use (penalized) LDA in the enlarged space, where the penalized
Mahalanobis distance is given by

D(x, µ) = (h(x)

−

h(µ))T (ΣW + λΩ)−1(h(x)

h(µ)),

(12.58)

−

where ΣW is the within-class covariance matrix of the derived vari-
ables h(xi).

Decompose the classiﬁcation subspace using a penalized metric:

•

•

•

max uT ΣBetu subject to uT (ΣW + λΩ)u = 1.

Loosely speaking, the penalized Mahalanobis distance tends to give less
weight to “rough” coordinates, and more weight to “smooth” ones; since
the penalty is not diagonal, the same applies to linear combinations that
are rough or smooth.

For some classes of problems, the ﬁrst step, involving the basis expansion,
is not needed; we already have far too many (correlated) predictors. A
leading example is when the objects to be classiﬁed are digitized analog
signals:

the log-periodogram of a fragment of spoken speech, sampled at a set
of 256 frequencies; see Figure 5.5 on page 149.

the grayscale pixel values in a digitized image of a handwritten digit.

•

•

12.6 Penalized Discriminant Analysis

447

LDA: Coefficient 1 PDA: Coefficient 1

LDA: Coefficient 2 PDA: Coefficient 2

LDA: Coefficient 3 PDA: Coefficient 3

LDA: Coefficient 4 PDA: Coefficient 4

LDA: Coefficient 5 PDA: Coefficient 5

LDA: Coefficient 6 PDA: Coefficient 6

LDA: Coefficient 7 PDA: Coefficient 7

LDA: Coefficient 8 PDA: Coefficient 8

LDA: Coefficient 9 PDA: Coefficient 9

FIGURE 12.11. The images appear in pairs, and represent the nine discrim-
inant coeﬃcient functions for the digit recognition problem. The left member of
each pair is the LDA coeﬃcient, while the right member is the PDA coeﬃcient,
regularized to enforce spatial smoothness.

It is also intuitively clear in these cases why regularization is needed.
Take the digitized image as an example. Neighboring pixel values will tend
to be correlated, being often almost the same. This implies that the pair
of corresponding LDA coeﬃcients for these pixels can be wildly diﬀerent
and opposite in sign, and thus cancel when applied to similar pixel values.
Positively correlated predictors lead to noisy, negatively correlated coeﬃ-
cient estimates, and this noise results in unwanted sampling variance. A
reasonable strategy is to regularize the coeﬃcients to be smooth over the
spatial domain, as with images. This is what PDA does. The computations
proceed just as for FDA, except that an appropriate penalized regression
method is used. Here hT (X)βℓ = Xβℓ, and Ω is chosen so that βT
ℓ Ωβℓ
penalizes roughness in βℓ when viewed as an image. Figure 1.2 on page 4
shows some examples of handwritten digits. Figure 12.11 shows the dis-
criminant variates using LDA and PDA. Those produced by LDA appear
as salt-and-pepper images, while those produced by PDA are smooth im-
ages. The ﬁrst smooth image can be seen as the coeﬃcients of a linear
contrast functional for separating images with a dark central vertical strip
(ones, possibly sevens) from images that are hollow in the middle (zeros,
some fours). Figure 12.12 supports this interpretation, and with more dif-
ﬁculty allows an interpretation of the second coordinate. This and other

448

12. Flexible Discriminants

1

1

1

1

2

1

4
1

2

1

1

1

1

1
1

1
1
1

1
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1 1
1
11 11
1
1
1
11
1
1
11
1
1
1
1
1
1
1
1
11
1
1
11
1
11
11
1 1
1
1
1
1
1
1
1
1
1
1
111
1
1
1
1
1
1
1
1
1 1
1 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
11
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1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
9
4
99
9
7
9
9
9
7
7
7
7
9
9
99
9
7
9
4
9
7
7
4
9
7
4
4
7
9
7
9
9
9
9
7
9
7
4
9
7
9
9
7
4
9
4
9
7
7
7
7
9
9
9
9
4
7
7
7
9
9
9
9
9
9
4
9
9
7
9
7
9
1
9
9
9
9
7
4
9
7
7
4
7
9
9
7
99
7
7
77
9
9
7
9
9
9
7
7
7
7
9
77
9
7
7
7
9
7
9
7
9
77
7
9
7
7
7
1
9
9
7
9
9
7
7
7
7
9
9
9
9
9
9
9
9
7
7
9
7
7
9 9
9
7
7
7
7
9
9
7
9
9
9
77
7
9
7
7
7
7
9
7
7
7
7
7
7
9
7
7
7
7
7
7
7

8
88
8
8

0
0
0

0
8
8

0
0

8
8
8

9
7

5
3

4
4

0

2

0

1

3

4

6

3

3

7

1

3

4

4

4

7

4

8
4

4
4
4
9
4
1

8
9
8
9
4
5
4
8
4
1
4
9
9

4

9 9

9

7
4
7

9
7
9

1

4

4
4
9
9
9
7
7

4
4

7

7

4

9

7

-5

0

5

PDA: Discriminant Coordinate 1

FIGURE 12.12. The ﬁrst two penalized canonical variates, evaluated for the
test data. The circles indicate the class centroids. The ﬁrst coordinate contrasts
mainly 0’s and 1’s, while the second contrasts 6’s and 7/9’s.

 
 
 
12.7 Mixture Discriminant Analysis

449

examples are discussed in more detail in Hastie et al. (1995), who also show
that the regularization improves the classiﬁcation performance of LDA on
independent test data by a factor of around 25% in the cases they tried.

12.7 Mixture Discriminant Analysis

Linear discriminant analysis can be viewed as a prototype classiﬁer. Each
class is represented by its centroid, and we classify to the closest using an
appropriate metric. In many situations a single prototype is not suﬃcient
to represent inhomogeneous classes, and mixture models are more appro-
priate. In this section we review Gaussian mixture models and show how
they can be generalized via the FDA and PDA methods discussed earlier.
A Gaussian mixture model for the kth class has density

Rk

G = k) =

πkrφ(X; µkr, Σ),

(12.59)

P (X

|

r=1
X
where the mixing proportions πkr sum to one. This has Rk prototypes for
the kth class, and in our speciﬁcation, the same covariance matrix Σ is
used as the metric throughout. Given such a model for each class, the class
posterior probabilities are given by

P (G = k

|

X = x) =

Rk
r=1 πkrφ(X; µkr, Σ)Πk

K
P
ℓ=1

Rℓ
r=1 πℓrφ(X; µℓr, Σ)Πℓ

,

(12.60)

where Πk represent the class prior probabilities.

P

P

We saw these calculations for the special case of two components in
Chapter 8. As in LDA, we estimate the parameters by maximum likelihood,
using the joint log-likelihood based on P (G, X):

K

Xk=1 Xgi=k

log

Rk

"

r=1
X

πkrφ(xi; µkr, Σ)Πk

.

#

(12.61)

The sum within the log makes this a rather messy optimization problem
if tackled directly. The classical and natural method for computing the
maximum-likelihood estimates (MLEs) for mixture distributions is the EM
algorithm (Dempster et al., 1977), which is known to possess good conver-
gence properties. EM alternates between the two steps:

450

12. Flexible Discriminants

E-step: Given the current parameters, compute the responsibility of sub-
class ckr within class k for each of the class-k observations (gi = k):

W (ckr|

xi, gi) =

πkrφ(xi; µkr, Σ)
Rk
ℓ=1 πkℓφ(xi; µkℓ, Σ)

.

(12.62)

P
M-step: Compute the weighted MLEs for the parameters of each of the
component Gaussians within each of the classes, using the weights
from the E-step.

In the E-step, the algorithm apportions the unit weight of an observation
in class k to the various subclasses assigned to that class. If it is close to the
centroid of a particular subclass, and far from the others, it will receive a
mass close to one for that subclass. On the other hand, observations halfway
between two subclasses will get approximately equal weight for both.

In the M-step, an observation in class k is used Rk times, to estimate the
parameters in each of the Rk component densities, with a diﬀerent weight
for each. The EM algorithm is studied in detail in Chapter 8. The algorithm
requires initialization, which can have an impact, since mixture likelihoods
are generally multimodal. Our software (referenced in the Computational
Considerations on page 455) allows several strategies; here we describe the
default. The user supplies the number Rk of subclasses per class. Within
class k, a k-means clustering model, with multiple random starts, is ﬁtted
to the data. This partitions the observations into Rk disjoint groups, from
which an initial weight matrix, consisting of zeros and ones, is created.

Our assumption of an equal component covariance matrix Σ throughout
buys an additional simplicity; we can incorporate rank restrictions in the
mixture formulation just like in LDA. To understand this, we review a little-
known fact about LDA. The rank-L LDA ﬁt (Section 4.3.3) is equivalent to
the maximum-likelihood ﬁt of a Gaussian model,where the diﬀerent mean
vectors in each class are conﬁned to a rank-L subspace of IRp (Exercise 4.8).
We can inherit this property for the mixture model, and maximize the log-
likelihood (12.61) subject to rank constraints on all the
k Rk centroids:
rank

= L.

Again the EM algorithm is available, and the M-step turns out to be
K
a weighted version of LDA, with R =
k=1 Rk “classes.” Furthermore,
we can use optimal scoring as before to solve the weighted LDA problem,
which allows us to use a weighted version of FDA or PDA at this stage.
One would expect, in addition to an increase in the number of “classes,” a
similar increase in the number of “observations” in the kth class by a factor
of Rk. It turns out that this is not the case if linear operators are used for
the optimal scoring regression. The enlarged indicator Y matrix collapses
in this case to a blurred response matrix Z, which is intuitively pleasing.
For example, suppose there are K = 3 classes, and Rk = 3 subclasses per
class. Then Z might be

P

µkℓ}
{

P

12.7 Mixture Discriminant Analysis

451

c11
0
0.9
0.1
0
0

c12
0
0.1
0.8
0
0

c13
0
0.0
0.1
0
0

0

0

0

c21
0.3
0
0
0
0.7
...
0

c22
0.5
0
0
0
0.1

c23
0.2
0
0
0
0.2

c31
0
0
0
0.5
0

c32
0
0
0
0.4
0

0

0

0.1

0.1

g1 = 2
g2 = 1
g3 = 1
g4 = 3
g5 = 2
...
gN = 3














where the entries in a class-k row correspond to W (ckr|

The remaining steps are the same:

c33
0
0
0
0.1
0













x, gi).

0.8

,

(12.63)

ˆZ = SZ
ZT ˆZ = ΘDΘT
Update πs and Πs




M-step of MDA.


These simple modiﬁcations add considerable ﬂexibility to the mixture

model:

•

The dimension reduction step in LDA, FDA or PDA is limited by
the number of classes; in particular, for K = 2 classes no reduction is
possible. MDA substitutes subclasses for classes, and then allows us
to look at low-dimensional views of the subspace spanned by these
subclass centroids. This subspace will often be an important one for
discrimination.

•

By using FDA or PDA in the M-step, we can adapt even more to par-
ticular situations. For example, we can ﬁt MDA models to digitized
analog signals and images, with smoothness constraints built in.

Figure 12.13 compares FDA and MDA on the mixture example.

12.7.1 Example: Waveform Data

We now illustrate some of these ideas on a popular simulated example,
taken from Breiman et al. (1984, pages 49–55), and used in Hastie and
Tibshirani (1996b) and elsewhere. It is a three-class problem with 21 vari-
ables, and is considered to be a diﬃcult pattern recognition problem. The
predictors are deﬁned by

Xj = U h1(j) + (1
Xj = U h1(j) + (1
Xj = U h2(j) + (1

U )h2(j) + ǫj
U )h3(j) + ǫj
U )h3(j) + ǫj

−

−
−

Class 1,

Class 2,
Class 3,

(12.64)

where j = 1, 2, . . . , 21, U is uniform on (0, 1), ǫj are standard normal vari-
ates, and the hℓ are the shifted triangular waveforms: h1(j) = max(6

−

452

12. Flexible Discriminants

FDA / MARS - Degree 2

o

o

o

o

o

o

o

o

o
o

o
o

o
o

o
o
o
o

o
o
o
o
o

o
o
o
o

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
oo
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
oo
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . .
o
o
o
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
oo
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
o
. . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
. . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
o
. . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. .
. . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . .
. . . . . . . . . . . .
o
.
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . .
o
o
. . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . .
o
. . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . .
o
o
o
. . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.185
. . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.235
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o

o
o

o
o
o

o
o

o
o

o

o

o

o

o

o

MDA - 5 Subclasses per Class

o

o

o

o

o

o

o

o

o

o
o

o
o

•
•

•
•

o
o
o
o

o
o
o
o

. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
•
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
•
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
oo
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
•
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
•
o o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
o
•
o
o
o
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
o
• •
o
o
oo
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. .
o
o
•
o
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . .
o
o
o
o
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . .
. . . . . . . . . . . .
o
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . .
oo
o
o
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
. . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
. . .
. . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
•
. . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
o
. . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.17
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.22
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.21

o
o
o
o
o

o
o
o
o

•
•

•
•

•
•

o
o

o
o
o

o
o

o
o
o

o
o

.... .. .. . .

o
o

o

o

o

o

o

o

FIGURE 12.13. FDA and MDA on the mixture data. The upper plot uses
FDA with MARS as the regression procedure. The lower plot uses MDA with
ﬁve mixture centers per class (indicated). The MDA solution is close to Bayes
optimal, as might be expected given the data arise from mixtures of Gaussians.
The broken purple curve in the background is the Bayes decision boundary.

12.7 Mixture Discriminant Analysis

453

Class 1

4
3
5

2
1

4
3
5

2
1

4
3
5

2
1

Class 2

3
2
1

5
4

3
2
1

5
4

3
2
1

5
4

Class 3

5
4
2
1
3

5
3
1
2
4

3
1
2
4
5

4
3
5

2
1

5
3
2
4
1

5
4
2
1

3

1
2

5
3
4

3
2
1

5
4

3

1
2
4
5

1
2

5
3

4

3
2
1
5
4

3

1
2
4
5

1
2

5
3
4

3
2
1

5
4

3

1
2
4
5

5
3
2
4
1

3
2
1

5
4

3

1
2
4
5

1
2

5
3

4

1
2

5
3
4

1
2

5
3
4

1
2
5
3
4

5
3
2
4
1

5
3
4
1
2

5
3
4
1
2

5
3
4
1
2

5
3
4
1
2

5
3
4
1
2

3

1
2
4
5

3

1
2
4
5

3
1
2
4
5

3
1
2
4
5

5
3
1
4
2

4
3
5

2
1

4
5

1
2
3

5
4
2
1

3

4
3
5

2
1

4
5

1
2
3

5
4
2
1

3

4
3
5
2
1

4
5

1
2
3

5
4
2
1

3

5
3
1
4
2

5
3
1
4
2

5
3
1
4
2

5
3
1
4
2

5
3
1
4
2

4
5

1
2
3

5
4
2
1

3

4
5

1
2
3

5
4
2
1

3

4
5

1
2
3

5
4
2
1
3

4
5
1
2
3

5
3
1
4
2

5
4
2
1
3

5
3
1
4
2

FIGURE 12.14. Some examples of the waveforms generated from model (12.64)
before the Gaussian noise is added.

, 0), h2(j) = h1(j

j
|
some example waveforms from each class.

11
|

−

−

4) and h3(j) = h1(j + 4). Figure 12.14 shows

Table 12.4 shows the results of MDA applied to the waveform data, as
well as several other methods from this and other chapters. Each train-
ing sample has 300 observations, and equal priors were used, so there are
roughly 100 observations in each class. We used test samples of size 500.
The two MDA models are described in the caption.

Figure 12.15 shows the leading canonical variates for the penalized MDA
model, evaluated at the test data. As we might have guessed, the classes
appear to lie on the edges of a triangle. This is because the hj(i) are repre-
sented by three points in 21-space, thereby forming vertices of a triangle,
and each class is represented as a convex combination of a pair of vertices,
and hence lie on an edge. Also it is clear visually that all the information
lies in the ﬁrst two dimensions; the percentage of variance explained by the
ﬁrst two coordinates is 99.8%, and we would lose nothing by truncating the
solution there. The Bayes risk for this problem has been estimated to be
about 0.14 (Breiman et al., 1984). MDA comes close to the optimal rate,
which is not surprising since the structure of the MDA model is similar to
the generating model.

454

12. Flexible Discriminants

TABLE 12.4. Results for waveform data. The values are averages over ten sim-
ulations, with the standard error of the average in parentheses. The ﬁve entries
above the line are taken from Hastie et al. (1994). The ﬁrst model below the line
is MDA with three subclasses per class. The next line is the same, except that the
discriminant coeﬃcients are penalized via a roughness penalty to eﬀectively 4df.
The third is the corresponding penalized LDA or PDA model.

Technique

Error Rates

Training

Test

LDA
QDA
CART
FDA/MARS (degree = 1)
FDA/MARS (degree = 2)
MDA (3 subclasses)
MDA (3 subclasses, penalized 4 df)
PDA (penalized 4 df)
Bayes

0.121(0.006)
0.039(0.004)
0.072(0.003)
0.100(0.006)
0.068(0.004)
0.087(0.005)
0.137(0.006)
0.150(0.005)

0.191(0.006)
0.205(0.006)
0.289(0.004)
0.191(0.006)
0.215(0.002)
0.169(0.006)
0.157(0.005)
0.171(0.005)
0.140

3 Subclasses, Penalized 4 df

3 Subclasses, Penalized 4 df

1

3

2

r
a
V

t
n
a
n
m

i

i
r
c
s
D

i

4

2

0

2
-

4
-

6
-

1
11
1
3

3
1

1

3

3

3
3
33

3

3

3

3
3
3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2

1

3

3

1

Discriminant Var 1

Discriminant Var 3

FIGURE 12.15. Some two-dimensional views of the MDA model ﬁtted to a
sample of the waveform model. The points are independent test data, projected
on to the leading two canonical coordinates (left panel), and the third and fourth
(right panel). The subclass centers are indicated.

 
 
 
 
Exercises

455

Computational Considerations

With N training cases, p predictors, and m support vectors, the support
vector machine requires m3 + mN + mpN operations, assuming m
N .
They do not scale well with N , although computational shortcuts are avail-
able (Platt, 1999). Since these are evolving rapidly, the reader is urged to
search the web for the latest technology.

≈

LDA requires N p2 + p3 operations, as does PDA. The complexity of
FDA depends on the regression method used. Many techniques are linear
in N , such as additive models and MARS. General splines and kernel-based
regression methods will typically require N 3 operations.

Software is available for ﬁtting FDA, PDA and MDA models in the R

package mda, which is also available in S-PLUS.

Bibliographic Notes

The theory behind support vector machines is due to Vapnik and is de-
scribed in Vapnik (1996). There is a burgeoning literature on SVMs; an
online bibliography, created and maintained by Alex Smola and Bernhard
Sch¨olkopf, can be found at:

http://www.kernel-machines.org.
Our treatment is based on Wahba et al. (2000) and Evgeniou et al. (2000),
and the tutorial by Burges (Burges, 1998).

Linear discriminant analysis is due to Fisher (1936) and Rao (1973). The
connection with optimal scoring dates back at least to Breiman and Ihaka
(1984), and in a simple form to Fisher (1936). There are strong connections
with correspondence analysis (Greenacre, 1984). The description of ﬂexible,
penalized and mixture discriminant analysis is taken from Hastie et al.
(1994), Hastie et al. (1995) and Hastie and Tibshirani (1996b), and all
three are summarized in Hastie et al. (2000); see also Ripley (1996).

Exercises

Ex. 12.1 Show that the criteria (12.25) and (12.8) are equivalent.

Ex. 12.2 Show that the solution to (12.29) is the same as the solution to
(12.25) for a particular kernel.

Ex. 12.3 Consider a modiﬁcation to (12.43) where you do not penalize the
constant. Formulate the problem, and characterize its solution.

Ex. 12.4 Suppose you perform a reduced-subspace linear discriminant anal-
ysis for a K-group problem. You compute the canonical variables of di-

456

12. Flexible Discriminants

1 given by z = UT x, where U is the p
mension L
discriminant coeﬃcients, and p > K is the dimension of x.

K

≤

−

L matrix of

×

(a) If L = K

1 show that

2

−
z
−
k
k·kW denotes Mahalanobis distance with respect to the covari-

2
x
W − k

2
W ,
k

¯xkk

¯zkk

2 =

− k

¯xk′

¯zk′

−

−

−

x

k

k

z

where
ance W.

(b) If L < K

1, show that the same expression on the left measures
the diﬀerence in Mahalanobis squared distances for the distributions
projected onto the subspace spanned by U.

−

Ex. 12.5 The data in phoneme.subset, available from this book’s website

http://www-stat.stanford.edu/ElemStatLearn

consists of digitized log-periodograms for phonemes uttered by 60 speakers,
each speaker having produced phonemes from each of ﬁve classes. It is
appropriate to plot each vector of 256 “features” against the frequencies
0–255.

(a) Produce a separate plot of all the phoneme curves against frequency

for each class.

(b) You plan to use a nearest prototype classiﬁcation scheme to classify
the curves into phoneme classes. In particular, you will use a K-means
clustering algorithm in each class (kmeans() in R), and then classify
observations to the class of the closest cluster center. The curves are
high-dimensional and you have a rather small sample-size-to-variables
ratio. You decide to restrict all the prototypes to be smooth functions
of frequency. In particular, you decide to represent each prototype m
as m = Bθ where B is a 256
J matrix of natural spline basis
×
functions with J knots uniformly chosen in (0, 255) and boundary
knots at 0 and 255. Describe how to proceed analytically, and in
particular, how to avoid costly high-dimensional ﬁtting procedures.
(Hint: It may help to restrict B to be orthogonal.)

(c) Implement your procedure on the phoneme data, and try it out. Divide
the data into a training set and a test set (50-50), making sure that
speakers are not split across sets (why?). Use K = 1, 3, 5, 7 centers
per class, and for each use J = 5, 10, 15 knots (taking care to start
the K-means procedure at the same starting values for each value of
J), and compare the results.

Ex. 12.6 Suppose that the regression procedure used in FDA (Section 12.5.1)
is a linear expansion of basis functions hm(x), m = 1, . . . , M . Let Dπ =
YT Y/N be the diagonal matrix of class proportions.

(a) Show that the optimal scoring problem (12.52) can be written in vector

Exercises

457

notation as

min
θ,β k
where θ is a vector of K real numbers, and H is the N
of evaluations hj(xi).

−

k

Hβ

Yθ

2 ,

(12.65)

M matrix

×

(b) Suppose that the normalization on θ is θT Dπ1 = 0 and θT Dπθ = 1.
Interpret these normalizations in terms of the original scored θ(gi).

(c) Show that, with this normalization, (12.65) can be partially optimized

w.r.t. β, and leads to

θT YT SYθ,

max
θ

(12.66)

subject to the normalization constraints, where S is the projection
operator corresponding to the basis matrix H.

(d) Suppose that the hj include the constant function. Show that the

largest eigenvalue of S is 1.

(e) Let Θ be a K

×

K matrix of scores (in columns), and suppose the
normalization is ΘT DπΘ = I. Show that the solution to (12.53) is
given by the complete set of eigenvectors of S; the ﬁrst eigenvector is
trivial, and takes care of the centering of the scores. The remainder
characterize the optimal scoring solution.

Ex. 12.7 Derive the solution to the penalized optimal scoring problem
(12.57).

Ex. 12.8 Show that coeﬃcients βℓ found by optimal scoring are proportional
to the discriminant directions νℓ found by linear discriminant analysis.
Ex. 12.9 Let ˆY = X ˆB be the ﬁtted N
linear regression on the N
features x∗
original space.

K indicator response matrix after
p matrix X, where p > K. Consider the reduced
i is equivalent to LDA in the

×
i = ˆBT xi. Show that LDA using x∗

×

Ex. 12.10 Kernels and linear discriminant analysis. Suppose you wish to
carry out a linear discriminant analysis (two classes) using a vector of
transformations of the input variables h(x). Since h(x) is high-dimensional,
you will use a regularized within-class covariance matrix Wh + γI. Show
that the model can be estimated using only the inner products K(xi, xi′ ) =
h(xi), h(xi′ )
. Hence the kernel property of support vector machines is also
h
shared by regularized linear discriminant analysis.

i

Ex. 12.11 The MDA procedure models each class as a mixture of Gaussians.
Hence each mixture center belongs to one and only one class. A more
general model allows each mixture center to be shared by all classes. We
take the joint density of labels and features to be

458

12. Flexible Discriminants

R

P (G, X) =

πrPr(G, X),

(12.67)

r=1
X

a mixture of

joint densities. Furthermore we assume

Pr(G, X) = Pr(G)φ(X; µr, Σ).

(12.68)

This model consists of regions centered at µr, and for each there is a class
proﬁle Pr(G). The posterior class distribution is given by

P (G = k

|

X = x) =

R
r=1 πrPr(G = k)φ(x; µr, Σ)
R
r=1 πrφ(x; µr, Σ)

,

P

(12.69)

where the denominator is the marginal distribution P (X).

P

(a) Show that this model (called MDA2) can be viewed as a generalization

of MDA since

P (X

|

G = k) =

R
r=1 πrPr(G = k)φ(x; µr, Σ)
R
r=1 πrPr(G = k)

,

P

(12.70)

where πrk = πrPr(G = k)/
mixing proportions for the kth class.

R
r=1 πrPr(G = k) corresponds to the

P

P

(b) Derive the EM algorithm for MDA2.

(c) Show that if the initial weight matrix is constructed as in MDA, in-
volving separate k-means clustering in each class, then the algorithm
for MDA2 is identical to the original MDA procedure.

This is page 459
Printer: Opaque this

13
Prototype Methods and
Nearest-Neighbors

13.1

Introduction

In this chapter we discuss some simple and essentially model-free methods
for classiﬁcation and pattern recognition. Because they are highly unstruc-
tured, they typically are not useful for understanding the nature of the
relationship between the features and class outcome. However, as black box
prediction engines, they can be very eﬀective, and are often among the best
performers in real data problems. The nearest-neighbor technique can also
be used in regression; this was touched on in Chapter 2 and works reason-
ably well for low-dimensional problems. However, with high-dimensional
features, the bias–variance tradeoﬀ does not work as favorably for nearest-
neighbor regression as it does for classiﬁcation.

13.2 Prototype Methods

Throughout this chapter, our training data consists of the N pairs (x1, g1),
. . . , (xn, gN ) where gi is a class label taking values in
. Pro-
}
totype methods represent the training data by a set of points in feature
space. These prototypes are typically not examples from the training sam-
ple, except in the case of 1-nearest-neighbor classiﬁcation discussed later.
Each prototype has an associated class label, and classiﬁcation of a query
point x is made to the class of the closest prototype. “Closest” is usually
deﬁned by Euclidean distance in the feature space, after each feature has

1, 2, . . . , K
{

460

13. Prototypes and Nearest-Neighbors

been standardized to have overall mean 0 and variance 1 in the training
sample. Euclidean distance is appropriate for quantitative features. We
discuss distance measures between qualitative and other kinds of feature
values in Chapter 14.

These methods can be very eﬀective if the prototypes are well positioned
to capture the distribution of each class. Irregular class boundaries can be
represented, with enough prototypes in the right places in feature space.
The main challenge is to ﬁgure out how many prototypes to use and where
to put them. Methods diﬀer according to the number and way in which
prototypes are selected.

13.2.1 K-means Clustering

K-means clustering is a method for ﬁnding clusters and cluster centers in a
set of unlabeled data. One chooses the desired number of cluster centers, say
R, and the K-means procedure iteratively moves the centers to minimize
the total within cluster variance.1 Given an initial set of centers, the K-
means algorithm alternates the two steps:

•

•

for each center we identify the subset of training points (its cluster)
that is closer to it than any other center;

the means of each feature for the data points in each cluster are
computed, and this mean vector becomes the new center for that
cluster.

These two steps are iterated until convergence. Typically the initial centers
are R randomly chosen observations from the training data. Details of the
K-means procedure, as well as generalizations allowing for diﬀerent variable
types and more general distance measures, are given in Chapter 14.

To use K-means clustering for classiﬁcation of labeled data, the steps

are:

•

•

•

apply K-means clustering to the training data in each class sepa-
rately, using R prototypes per class;

assign a class label to each of the K

R prototypes;

×

classify a new feature x to the class of the closest prototype.

Figure 13.1 (upper panel) shows a simulated example with three classes
and two features. We used R = 5 prototypes per class, and show the clas-
siﬁcation regions and the decision boundary. Notice that a number of the

1The “K” in K-means refers to the number of cluster centers. Since we have already

reserved K to denote the number of classes, we denote the number of clusters by R.

13.2 Prototype Methods

461

K-means - 5 Prototypes  per Class

o

o

o

o

o

o

o

o
o

o
o
o

•
•

•
•

•
•

•
•

o
o
o
o

...............
...................................................................................................
.................
.................................................................................................
..................
................................................................................................
...................
...............................................................................................
....................
..............................................................................................
......................
............................................................................................
.......................
...........................................................................................
o
........................
..........................................................................................
.........................
.........................................................................................
...........................
.......................................................................................
............................
......................................................................................
.............................
.....................................................................................
o
o
..............................
....................................................................................
o
................................
..................................................................................
.................................
.................................................................................
..................................
................................................................................
...................................
...............................................................................
o
o
.....................................
.............................................................................
o
......................................
............................................................................
.......................................
...........................................................................
o
........................................
..........................................................................
o
o
o
o
o
o
o
..........................................
....
..........................................
..........................
o
o
o
o
o
........
...........................................
......................
.........................................
o
o
o
............
............................................
.........................................
.................
o
o
o
o
o
o
.................
.............................................
........................................
............
o
o
o
o
o
o
o
o
..............................................
......................
.......................................
.......
o
o
o
o
o
o
o
o
..........................................
.........................
.......................................
........
o
o
o
o
o
..........................
.....................................
......................................
.............
o
o
o
o
o
o
o
.................................
...........................
.....................................
.................
o
o
o
o
o
o
o
o
..........................
............................
.......................
.....................................
o
o
o
o o
o
o
o
o
o
o
o
o
........................
...........................
....................................
...........................
o
o
o
o
o
o
o
.............................
...................
...................................
...............................
o
o
o
o
o
o
o
o
...............................
...............
.................................
...................................
o
o
o
o
o
o
o
.................................
..........
...................................
....................................
o
o
o
o
oo
o
o
o
o
o
.................................
......
....................................
.......................................
o
o
o
o
o
•
o
...................................
.
....................................
..........................................
•
o
o
o
....................................
....................................
..........................................
o
•
ooo
o
o
o
o
o
o
•
o
o
o
......................................
....................................
........................................
o
o
o
o
o
o
o
o
o
.
.......................................
...................................
.......................................
o
o
o
o
o
o
o
o
......
...
............
.........................
.....................................
...............................
o
o
o
o
o
o
o
...........
........
.........
.........................
...................................
..........................
o
o
o
o
o
...................................
................
.............
.......................
......
.....................
o
o
o
o
o
o
o
.....................
.................
.......................................
...
..................
................
o
o
o
o
..........................
.....................
..........................................
.............
............
o
o
o
o
........................
.............................................
...............................
.........
.....
o
o
o
o
o
o
o
o
o
o
o
..........................................................
.............................................
...........
o
o
o
o
o
........................................................
.............................................
.............
o
o
o
o
o
o
......................................................
.............................................
...............
o
o
o
o
o o
o
....................................................
.............................................
.................
o
o
o
o
o
..................................................
.............................................
...................
o
o
o
o
o
o
o
................................................
.............................................
.....................
o
o
o
o
o
..............................................
.............................................
.......................
o
.............................................
............................................
.........................
o
o
o
o
o
............................................
..........................................
............................
o
o
o
o
............................................
..........................................
............................
o
o
............................................
..........................................
............................
............................................
..........................................
............................
o
o
o
.........................................
............................................
.............................
o
o
............................................
............................................
..........................
............................................
...............................................
.......................
o
o
o
..................................................
............................................
....................
oo
o
............................................
.....................................................
.................
o
..............................................
........................................................
............
................................................
...........................................................
.......
..................................................
..............................................................
..
o
..................................................................................................................
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................

•
•
•
•

•
•
•
•

•
•

•
•

•
•

•
•

•
•

o
o
o
o
o
o

o
o
o

o
o

o
o

o
o

o
o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

LVQ - 5 Prototypes per Class

o

o

o

o

o

o

o

o
o

o
o
o

•
•

•
•

•
•

•
•

o
o
o
o

.....................
.............................................................................................
......................
............................................................................................
.......................
...........................................................................................
........................
..........................................................................................
.........................
.........................................................................................
..........................
........................................................................................
...........................
.......................................................................................
o
............................
......................................................................................
............................
......................................................................................
.............................
.....................................................................................
..............................
....................................................................................
...............................
...................................................................................
o
o
................................
..................................................................................
o
.................................
.................................................................................
..................................
................................................................................
...................................
...............................................................................
....................................
..............................................................................
o
o
.....................................
.............................................................................
o
......................................
............................................................................
.......................................
...........................................................................
o
........................................
..........................................................................
o
o
o
o
o
o
o
.........................................
..
.........................................
..............................
o
o
o
o
o
........
..........................................
........................
........................................
o
o
o
..............
...........................................
........................................
.................
o
o
o
o
o
o
.....................
............................................
.......................................
..........
o
o
o
o
o
o
o
o
.......................................
............................
......................................
.........
o
o
o
o
o
o
o
o
..................................
..............................
.............
.....................................
o
o
o
o
o
..............................
.............................
.....................................
..................
o
o
•
o
o
o
o
o
o
o
........................
...............................
.......................
....................................
o
o
o
o
o
•
o
o
o
................................
...................
...................................
............................
o
o o
o
o
o
o
o
o
o
o
...............................
..............
....................................
.................................
o
o
o
o
o
o
o
...............................
.........
.....................................
.....................................
o
o
o
o
o
o
o
o
o
................................
....
.....................................
.........................................
o
o
o
•
o
o
o
o
.................................
............................................
.....................................
o
o
o
o
oo
o
o
o
o
..................................
.....................................
...........................................
o
o
o
•
o
o
o
....................................
....................................
..........................................
o
o
o
.....................................
....................................
.........................................
o
o
ooo
o
o
o
o
o
o
o
o
.....................................
.........................................
....................................
o
o
o
o
o
o
o
o
o
......................................
....................................
........................................
o
o
o
o
o
o
o
o
.......................................
.......................................
....................................
o
o
o
o
o
o
o
........................................
.
......................................
...................................
o
o
o
o
o
............................
.............
........
.....................................
............................
o
o
o
o
o
o
o
.............................
................
...............
..................
....................................
o
o
•
o
o
...........................
........
......................
....................
.....................................
o
o
o
o
o
.........................
.......................................
..................................................
•
o
o
o
o
o
o
o
o
o
o
o
........................
..................................................
........................................
o
o
o
o
o
......................
...................................................
.........................................
o
o
o
o
o
o
.....................
...................................................
..........................................
o
o
o
o
o o
o
o
..................
............................................
....................................................
o
o
o
o
o
.................
....................................................
.............................................
o
o
o
o
o
o
................
....................................................
..............................................
o
o
o
o
o
..............
...............................................
.....................................................
o
............
.....................................................
.................................................
o
o
o
o
o
..........
......................................................
..................................................
o
o
o
.........
......................................................
...................................................
o
o
o
.......
.....................................................
......................................................
.....
......................................................
.......................................................
o
o
o
o
o
.......
.......................................................
.......................................................
o
........................................................
.......................................................
..................................................................................................................
o
o
..................................................................................................................
oo
o
..................................................................................................................
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
o
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................

•
•
•
•

•
•

•
•

•
•

•
•

•
•

•
•

o
o
o
o
o
o

o
o
o

o
o

o
o

o
o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

FIGURE 13.1. Simulated example with three classes and ﬁve prototypes per
class. The data in each class are generated from a mixture of Gaussians. In the
upper panel, the prototypes were found by applying the K-means clustering algo-
rithm separately in each class. In the lower panel, the LVQ algorithm (starting
from the K-means solution) moves the prototypes away from the decision bound-
ary. The broken purple curve in the background is the Bayes decision boundary.

462

13. Prototypes and Nearest-Neighbors

Algorithm 13.1 Learning Vector Quantization—LVQ.

1. Choose R initial prototypes for each class: m1(k), m2(k), . . . , mR(k),
k = 1, 2, . . . , K, for example, by sampling R training points at random
from each class.

2. Sample a training point xi randomly (with replacement), and let (j, k)

index the closest prototype mj(k) to xi.

(a) If gi = k (i.e., they are in the same class), move the prototype

towards the training point:

mj(k)

mj(k) + ǫ(xi −

←

mj(k)),

where ǫ is the learning rate.

(b) If gi 6

away from the training point:

= k (i.e., they are in diﬀerent classes), move the prototype

mj(k)

mj(k)

ǫ(xi −

−

←

mj(k)).

3. Repeat step 2, decreasing the learning rate ǫ with each iteration to-

wards zero.

prototypes are near the class boundaries, leading to potential misclassiﬁca-
tion errors for points near these boundaries. This results from an obvious
shortcoming with this method: for each class, the other classes do not have
a say in the positioning of the prototypes for that class. A better approach,
discussed next, uses all of the data to position all prototypes.

13.2.2 Learning Vector Quantization

In this technique due to Kohonen (1989), prototypes are placed strategically
with respect to the decision boundaries in an ad-hoc way. LVQ is an online
algorithm—observations are processed one at a time.

The idea is that the training points attract prototypes of the correct class,
and repel other prototypes. When the iterations settle down, prototypes
should be close to the training points in their class. The learning rate ǫ is
decreased to zero with each iteration, following the guidelines for stochastic
approximation learning rates (Section 11.4.)

Figure 13.1 (lower panel) shows the result of LVQ, using the K-means
solution as starting values. The prototypes have tended to move away from
the decision boundaries, and away from prototypes of competing classes.

The procedure just described is actually called LVQ1. Modiﬁcations
(LVQ2, LVQ3, etc.) have been proposed, that can sometimes improve per-
formance. A drawback of learning vector quantization methods is the fact

13.3 k-Nearest-Neighbor Classiﬁers

463

that they are deﬁned by algorithms, rather than optimization of some ﬁxed
criteria; this makes it diﬃcult to understand their properties.

13.2.3 Gaussian Mixtures

The Gaussian mixture model can also be thought of as a prototype method,
similar in spirit to K-means and LVQ. We discuss Gaussian mixtures in
some detail in Sections 6.8, 8.5 and 12.7. Each cluster is described in terms
of a Gaussian density, which has a centroid (as in K-means), and a covari-
ance matrix. The comparison becomes crisper if we restrict the component
Gaussians to have a scalar covariance matrix (Exercise 13.1). The two steps
of the alternating EM algorithm are very similar to the two steps in K-
means:

•

In the E-step, each observation is assigned a responsibility or weight
for each cluster, based on the likelihood of each of the correspond-
ing Gaussians. Observations close to the center of a cluster will most
likely get weight 1 for that cluster, and weight 0 for every other clus-
ter. Observations half-way between two clusters divide their weight
accordingly.

•

In the M-step, each observation contributes to the weighted means
(and covariances) for every cluster.

As a consequence, the Gaussian mixture model is often referred to as a soft
clustering method, while K-means is hard.

}

Similarly, when Gaussian mixture models are used to represent the fea-
ture density in each class, it produces smooth posterior probabilities ˆp(x) =
for classifying x (see (12.60) on page 449.) Often this
ˆp1(x), . . . , ˆpK (x)
{
is interpreted as a soft classiﬁcation, while in fact the classiﬁcation rule is
ˆG(x) = arg maxk ˆpk(x). Figure 13.2 compares the results of K-means and
Gaussian mixtures on the simulated mixture problem of Chapter 2. We
see that although the decision boundaries are roughly similar, those for the
mixture model are smoother (although the prototypes are in approximately
the same positions.) We also see that while both procedures devote a blue
prototype (incorrectly) to a region in the northwest, the Gaussian mixture
classiﬁer can ultimately ignore this region, while K-means cannot. LVQ
gave very similar results to K-means on this example, and is not shown.

13.3 k-Nearest-Neighbor Classiﬁers

These classiﬁers are memory-based, and require no model to be ﬁt. Given
a query point x0, we ﬁnd the k training points x(r), r = 1, . . . , k closest in
distance to x0, and then classify using majority vote among the k neighbors.

464

13. Prototypes and Nearest-Neighbors

K-means - 5 Prototypes per Class

o

o

o

o
o

•
•

•
•

. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
.
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
.
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
.
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . .
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . .
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . .
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . .
o
o
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . .
o
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
o
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
•
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
•
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
oo
. . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
o
o
•
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
•
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
o
o
o
oo
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
.
o
•
o
o
oo
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
.
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . .
o
o
•
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
. . . .
o
o
o
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . .
o
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . .
oo
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . .
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . .
o
o
o
o
. . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
o
. . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
o
o
o
o
. . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
. . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
•
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
... .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.170
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.243
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o
o

o
o
o
o

•
•

•
•

•
•

•
•

o
o

o
o
o

o
o

o
o
o

o

o

o

o

o

Gaussian Mixtures - 5 Subclasses per Class

o

o

o

o

o

o

o

o

o

o
o

o
o

•
•

•
•

o
o
o
o

o
o
o
o

. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
o
. . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
•
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
o
o
. . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
•
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
•
o o
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
•
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
oo
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
• •
o
oo
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
•
o
o
. . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
o
o
o
. . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
o
. . . . . . . . . . . .
. . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
o
oo
. . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
o
. . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . .
. . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
o
oo
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . .
•
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . .
•
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . .
o
o
o
. . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.17
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.22
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.21

o
o
o
o
o

o
o
o
o

•
•

•
•

•
•

o
o

o
o
o

o
o

o
o
o

o
o

.... .. .. . .

o
o

o

o

o

o

o

o

FIGURE 13.2. The upper panel shows the K-means classiﬁer applied to the
mixture data example. The decision boundary is piecewise linear. The lower panel
shows a Gaussian mixture model with a common covariance for all component
Gaussians. The EM algorithm for the mixture model was started at the K-means
solution. The broken purple curve in the background is the Bayes decision
boundary.

13.3 k-Nearest-Neighbor Classiﬁers

465

Ties are broken at random. For simplicity we will assume that the features
are real-valued, and we use Euclidean distance in feature space:

.

||

x0||

d(i) =

x(i) −
Typically we ﬁrst standardize each of the features to have mean zero and
variance 1, since it is possible that they are measured in diﬀerent units. In
Chapter 14 we discuss distance measures appropriate for qualitative and
ordinal features, and how to combine them for mixed data. Adaptively
chosen distance metrics are discussed later in this chapter.

(13.1)

Despite its simplicity, k-nearest-neighbors has been successful in a large
number of classiﬁcation problems, including handwritten digits, satellite
image scenes and EKG patterns. It is often successful where each class
has many possible prototypes, and the decision boundary is very irregular.
Figure 13.3 (upper panel) shows the decision boundary of a 15-nearest-
neighbor classiﬁer applied to the three-class simulated data. The decision
boundary is fairly smooth compared to the lower panel, where a 1-nearest-
neighbor classiﬁer was used. There is a close relationship between nearest-
neighbor and prototype methods: in 1-nearest-neighbor classiﬁcation, each
training point is a prototype.

Figure 13.4 shows the training, test and tenfold cross-validation errors
as a function of the neighborhood size, for the two-class mixture problem.
Since the tenfold CV errors are averages of ten numbers, we can estimate
a standard error.

Because it uses only the training point closest to the query point, the bias
of the 1-nearest-neighbor estimate is often low, but the variance is high.
A famous result of Cover and Hart (1967) shows that asymptotically the
error rate of the 1-nearest-neighbor classiﬁer is never more than twice the
Bayes rate. The rough idea of the proof is as follows (using squared-error
loss). We assume that the query point coincides with one of the training
points, so that the bias is zero. This is true asymptotically if the dimension
of the feature space is ﬁxed and the training data ﬁlls up the space in a
dense fashion. Then the error of the Bayes rule is just the variance of a
Bernoulli random variate (the target at the query point), while the error of
1-nearest-neighbor rule is twice the variance of a Bernoulli random variate,
one contribution each for the training and query targets.

We now give more detail for misclassiﬁcation loss. At x let k∗ be the
dominant class, and pk(x) the true conditional probability for class k. Then

Bayes error = 1

−
K

pk∗(x),

1-nearest-neighbor error =

Xk=1
1
−

≥

pk(x)(1

pk(x)),

−

pk∗(x).

(13.2)

(13.3)

(13.4)

The asymptotic 1-nearest-neighbor error rate is that of a random rule; we
pick both the classiﬁcation and the test point at random with probabili-

466

13. Prototypes and Nearest-Neighbors

15-Nearest Neighbors

o

o

o

o

o

o

o

o
o

o
o
o

o
o
o
o

....................
..............................................................................................
.....................
.............................................................................................
.......................
...........................................................................................
........................
..........................................................................................
.........................
.........................................................................................
..........................
........................................................................................
...........................
.......................................................................................
o
...........................
.......................................................................................
............................
......................................................................................
.....................................................................................
.............................
..............................
....................................................................................
...................................................................................
...............................
o
o
...............................
...................................................................................
o
..................................................................................
................................
.................................
.................................................................................
..................................
................................................................................
...................................
...............................................................................
o
o
....................................
..............................................................................
o
......................................
............................................................................
.......................................
...........................................................................
o
........................................
.
.
................................................................... ... ..
o
o
o
o
o
o
o
.........................................
.........................................................................
o
o
o
o
o
..
..........................................
.
.................................................. .........
..........
o
o
o
.............
.............................................
..................................................
......
o
o
o
o
o
o
.................................................................
.................................................
o
o
o
o
o
o
o
o
. ..................................................................
.............................................. .
o
o
o
o
o
o
o
o
........................................................................
..........................................
o
o
o
o
o
...............................................................................
...................................
o
o
o
o
o
o
o
.............................
.............................................
...................................
.....
o
o
o
o
o
o
o
o
..........................................
........................
....................................
............
o
o
o
o o
o
o
o
o
o
o
o
o
........................
........................................
..................................
................
o
o
o
o
o
o
o
..................................... .. .
....
.
. .................
..................................
.. .
.........
.
o
o
o
o
o
o
o
o
.. .. .
...................................
.
. ................................ ..
...................................
.
..
o
o
o
o
o
o
o
........................................
...................................
.......................................
o
o
o
o
o
oo
o
o
o
o
. ...................................
........................................
..................................... .
o
o
o
o
o
o
..................................
........................................
........................................
o
o
o
.....................................
.....................................
........................................
o
ooo
o
o
o
o
o
o
o
o
o
.......................................
......................................
.....................................
o
o
o
o
o
o
o
o
o
......
.........
................................
...........................
........................................
o
o
o
o
o
o
o
o
.
.............
..........
................................
........................................
.. ................
o
o
o
o
o
o
o
....................
....................
.................................
.......................................
..
o
o
o
o
o
..........................................
.................................
.......................................
o
o
o
o
o
o
o
.......
..........................................
...
.
....
...........................
.......... ....................
o
o
o
o
.................
............................................
....
.........................
....
....................
o
o
o
o
o
..........
................................................
........................
.................
...............
o
o
o
o
o
o
o
o
o
o
o
........................
. .
..............
....
...................................................
............
.. . ..
..
o
o
o
o
o
..................................
................................................
....................
..........
..
o
o
o
o
o
o
o
...................................................
.......................................................
........
o
o
o
o
o o
o
.......................................................
....................................................
.......
o
o
o
o
o
o
.............................................
.....................................................
......
....
......
o
o
o
o
o
o
o
o
.........................................................
...........................................
....
.....
.....
o
o
o
o
o
.....
.
...
...........................................
..... ....................................................
.....
o
..........................................
..........................................................
......
..
......
o
o
o
o
o
.....................................................
...........................................................
..
o
o
o
o
..................................................................................................................
o
o
o
...........................................................
....................................................
. ....
................................................. . ..............................................................
o
o
o
..................................................................................................................
o
o
..................................................................................................................
..................................................................................................................
o
o
..................................................................................................................
oo
o
..................................................................................................................
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
o
..................................................................................................................
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................

o
o
o
o
o
o

o
o
o

o
o

o
o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

....

o

o

1-Nearest Neighbor

o

o

o

o

o

o

o

o

o
o

o
o
o

o
o
o
o

............................................................................................
......................
...........................................................................................
.......................
...........................................................................................
.......................
..........................................................................................
........................
.........................................................................................
.........................
........................................................................................
..........................
........................................................................................
..........................
o
.......................................................................................
...........................
......................................................................................
............................
.....................................................................................
.............................
.............................
.....................................................................................
....................................................................................
..............................
o
o
...................................................................................
...............................
o
..................................................................................
................................
..................................................................................
................................
................................................................................
..................................
..............................................................................
....................................
o
..............................................................................
....................................
o
...............................................................................
...................................
......................................................................
.......
...................................
..
o
......................................................................
......
...................................
...
o
o
o
o
o
o
o
.....................................................................
.....
...................................
.....
o
o
o
o
o
.........
.........................................................
..............................................
..
o
o
o
.
........................................................
.....
.......... .......................................
...
o
o
o
o
o
o
.......
............................................
..
....
......
...................................
..........
......
o
o
o
o
o
o
o
o
......
.............................................
.
......
........
.......... ...
...................................
o
o
o
o
o
o
o
o
..............................................
......
.....
.....
........
...
......
...................................
o
o
o
o
o
.............................
....
.......
.
.
........... ....
.............. .....................
......... .....
....
...
.
o
o
o
o
o
o
o
............................
.....
..
..
..
..
......
................
.......................
.....................
....
...
o
o
o
o
o
o
o
o
............................
...
.......
...
..
..
.
.......
.......... ...............
....
...
........
.....................
o
o
o
o o
o
o
o
o
o
o
o
o
........................
............................. .....
........
.....................
.
.....
.....................
o
o
o
o
o
o
o
...................................
........................
......
.......................
......
....................
o
o
o
o
o
o
o
o
.........................................
......................
...
......
.......................
...................
o
o
o
o
o
o
o
.......................
.
..
................................
...
............ .......................
..................
o
o
o
o
oo
o
o
o
o
o
..................
...................................
..
..............................
.....................
........
o
o
o
o
o
o
...........................
.............
.....
.
......
....
.......................
....... ............
..............
..
o
o
o
......
...........
.
......
........................
.......
.....
......
..
....... ..
......
........................
......
.
o
ooo
o
o
o
o
o
o
o
o
o
............
...
..
....................................
.......
.........
.
.....
....
.
.. ..
..
.......................
.....
o
o
o
o
o
o
o
o
o
............
..............................
.........
.............
....
...
.......
.............
.......................
o
o
o
o
o
o
o
o
...........
...........................
....
..........
....
.....
..
..........
.............
...................
.........
o
o
o
o
o
o
o
....................
.
............
.....
...
...........
...................
.......
...............
...
......
.......
.....
o
o
o
o
o
..
..................
....................................
............
...
........
...
.
........
.............
.....
.....
o
o
o
o
o
o
o
...
...............
.............
....................................
.........
.....
...
........
..............
...
.....
o
o
o
o
...
............
.....
..................................
..............
.........
..........
....
............
......
.....
o
o
o
o
o
..........
...............................
..............
..........
........
..................
........
............
...
o
o
o
o
o
o
o
o
o
o
o
..........
................................
..........
...............
.............
..... ...
......
..
..
....
.....
.
..
....
o
o
o
o
o
..............
.............
.......
... ...................................
............
.
......
..
.
....... ...
..........
o
o
o
o
o
o
o
.............
.............. .....
.....................................
............
.....
.....
...
..
.....
.
......
......
o
o
o
o
o
o o
o
......
..........
..................
..
..
.............................................
...............
...
.............
o
o
o
o
o
o
.......
.......
...
..................
.........................................
...
....
............
.....
....
.....
.....
o
o
o
o
o
o
o
....
...........
........ .....
.
..
....................
.................................................
..............
o
o
o
o
o
o
o
.............
....................
................................................
.......
..
......
....
.........
.....
o
...........
........................................
.....................
......
....
..........
.............
....
.....
o
o
o
o
o
..........
.........................................
.....................
...
.......
............
.............
.....
..
o
o
o
o
o
.......
.......................................
.......................
...
.........
..............
...
.............
...
o
o
..................................
...............
............................................
..........
...........
..................
...........................................
...................................
.......
...........
o
o
o
...........................................
.......................
...................................
...
..........
o
o
.................................................
...........................................
...........
..
.........
.............................................
..............................................
..........
........
.....
o
o
o
.............................................
..........................................................
...........
oo
o
................................................................... ..............................................
.
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
o
..................................................................................................................
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
o
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................

o
o
o
o
o
o

o
o
o

o
o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

o

FIGURE 13.3. k-nearest-neighbor classiﬁers applied to the simulation data of
Figure 13.1. The broken purple curve in the background is the Bayes decision
boundary.

13.3 k-Nearest-Neighbor Classiﬁers

467

s
r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

i

l

0
3
.
0

5
2
.
0

0
2
.
0

5
1
.
0

0
1
.
0

5
0
.
0

0
.
0

•

•

•

• • • •
•

• • • • • • • • • •
• • • • •
• • • • • • •

•

• • • • • • •
• •
• •

•

• •

Test Error
10-fold CV
Training Error
Bayes Error

0

5

10

15

20

25

30

Number of Neighbors

7-Nearest Neighbors

o

o

o

o

o

o

o

o

o
o

o
o

. . . . . . . . . . . . . . .

o
o
o
o

. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . .
o
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
.
. . . . . . . . . . .
.
.
o
o
oo
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
.
o
o
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. .
.
. . . . . . . . . . . .
.
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . .
. . .
. . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
o
o
o
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
oo
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
oo
o
o
. . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. .
. . . . .
. . . . . . . . . . . .
.
.
.
o
o
o
o
. . . .
.
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . .
. .
.
.
o
o
o
. .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . .
. . . .
. . . .
o
o
o
o
o
o
.
. . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . .
. . . . .
o
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . .
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . .
oo
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
o
. . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
. . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . .
o
o
. . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . .
. . . .
. . . . . . . . . . .
.
. . . . . . . . . . . . . . . . .
o
o
o
o
o
. . . . . . . . . .
. . . .
. . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . .
o
o
o
o
. . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
. . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
o
. . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
o
o
o
. . . . . . . .
. . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . .
. . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . .
. . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
o
o
o
o
o
. . . . . .
. . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . .
. . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
oo
. . .
. . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
.
. . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . .
. . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
. . .
. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . .
. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
.. .. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
o
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Training Error: 0.145
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Error:       0.225
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bayes Error:    0.210

o
o
o
o
o

o
o
o
o

o
o
o

o
o

o
o

o

o

o

o

o

o

FIGURE 13.4. k-nearest-neighbors on the two-class mixture data. The upper
panel shows the misclassiﬁcation errors as a function of neighborhood size. Stan-
dard error bars are included for 10-fold cross validation. The lower panel shows
the decision boundary for 7-nearest-neighbors, which appears to be optimal for
minimizing test error. The broken purple curve in the background is the Bayes
decision boundary.

 
468

13. Prototypes and Nearest-Neighbors

ties pk(x), k = 1, . . . , K. For K = 2 the 1-nearest-neighbor error rate is
2pk∗(x)(1
pk∗(x)) (twice the Bayes error rate). More
generally, one can show (Exercise 13.3)

pk∗(x))

2(1

−

≤

−

K

Xk=1

pk(x)(1

pk(x))

2(1

−

≤

−

pk∗(x))

−

K

K

−

(1

1

−

pk∗(x))2.

(13.5)

Many additional results of this kind have been derived; Ripley (1996) sum-
marizes a number of them.

This result can provide a rough idea about the best performance that
is possible in a given problem. For example, if the 1-nearest-neighbor rule
has a 10% error rate, then asymptotically the Bayes error rate is at least
5%. The kicker here is the asymptotic part, which assumes the bias of the
nearest-neighbor rule is zero. In real problems the bias can be substantial.
The adaptive nearest-neighbor rules, described later in this chapter, are an
attempt to alleviate this bias. For simple nearest-neighbors, the bias and
variance characteristics can dictate the optimal number of near neighbors
for a given problem. This is illustrated in the next example.

13.3.1 Example: A Comparative Study

We tested the nearest-neighbors, K-means and LVQ classiﬁers on two sim-
ulated problems. There are 10 independent features Xj, each uniformly
distributed on [0, 1]. The two-class 0-1 target variable is deﬁned as follows:

1
2

(cid:19)
3

Y = I

X1 >

;

problem 1: “easy”,

(cid:18)



sign

Y = I



Xj −

1
2




(cid:19)




j=1 (cid:18)
Y



> 0



;

problem 2: “diﬃcult.”

(13.6)





Hence in the ﬁrst problem the two classes are separated by the hyperplane
X1 = 1/2; in the second problem, the two classes form a checkerboard
pattern in the hypercube deﬁned by the ﬁrst three features. The Bayes
error rate is zero in both problems. There were 100 training and 1000 test
observations.

Figure 13.5 shows the mean and standard error of the misclassiﬁcation
error for nearest-neighbors, K-means and LVQ over ten realizations, as
the tuning parameters are varied. We see that K-means and LVQ give
nearly identical results. For the best choices of their tuning parameters,
K-means and LVQ outperform nearest-neighbors for the ﬁrst problem, and
they perform similarly for the second problem. Notice that the best value
of each tuning parameter is clearly situation dependent. For example 25-
nearest-neighbors outperforms 1-nearest-neighbor by a factor of 70% in the

13.3 k-Nearest-Neighbor Classiﬁers

469

Nearest Neighbors / Easy

K-means & LVQ / Easy

5
.
0

r
o
r
r

4
.
0

5
.
0

r
o
r
r

4
.
0

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

l

i

0

20

40

60

Number of Neighbors

Nearest Neighbors / Difficult

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

i

l

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

l

i

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

i

l

3
.
0

2
.
0

1
.
0

0
6
.
0

5
5
.
0

0
5
.
0

5
4
.
0

0
4
.
0

0

5

10

15

20

25

30

Number of Prototypes per Class

K-means & LVQ / Difficult

3
.
0

2
.
0

1
.
0

0
6
.
0

5
5
.
0

0
5
.
0

5
4
.
0

0
4
.
0

0

20

40

60

0

5

10

15

20

25

30

Number of Neighbors

Number of Prototypes per Class

FIGURE 13.5. Mean
one standard error of misclassiﬁcation error for near-
est-neighbors, K-means (blue) and LVQ (red) over ten realizations for two sim-
ulated problems: “easy” and “diﬃcult,” described in the text.

±

 
 
 
 
470

13. Prototypes and Nearest-Neighbors

Spectral Band 1

Spectral Band 2

Spectral Band 3

Spectral Band 4

Land Usage

Predicted Land Usage

FIGURE 13.6. The ﬁrst four panels are LANDSAT images for an agricultural
area in four spectral bands, depicted by heatmap shading. The remaining two
panels give the actual land usage (color coded) and the predicted land usage using
a ﬁve-nearest-neighbor rule described in the text.

ﬁrst problem, while 1-nearest-neighbor is best in the second problem by a
factor of 18%. These results underline the importance of using an objective,
data-based method like cross-validation to estimate the best value of a
tuning parameter (see Figure 13.4 and Chapter 7).

13.3.2 Example: k-Nearest-Neighbors and Image Scene

Classiﬁcation

×

The STATLOG project (Michie et al., 1994) used part of a LANDSAT
image as a benchmark for classiﬁcation (82
100 pixels). Figure 13.6 shows
four heat-map images, two in the visible spectrum and two in the infrared,
for an area of agricultural land in Australia. Each pixel has a class label
red soil, cotton, vegetation stubble, mixture,
from the 7-element set
{
G
gray soil, damp gray soil, very damp gray soil
, determined manually by
}
research assistants surveying the area. The lower middle panel shows the
actual land usage, shaded by diﬀerent colors to indicate the classes. The
objective is to classify the land usage at a pixel, based on the information
in the four spectral bands.

=

Five-nearest-neighbors produced the predicted map shown in the bot-
tom right panel, and was computed as follows. For each pixel we extracted
an 8-neighbor feature map—the pixel itself and its 8 immediate neighbors

13.3 k-Nearest-Neighbor Classiﬁers

471

N(cid:10)

N(cid:10)

N(cid:10)

N(cid:10)

X(cid:10)

N(cid:10)

N(cid:10)

N(cid:10)

N(cid:10)

FIGURE 13.7. A pixel and its 8-neighbor feature map.

×

(see Figure 13.7). This is done separately in the four spectral bands, giving
(1 + 8)
4 = 36 input features per pixel. Then ﬁve-nearest-neighbors classi-
ﬁcation was carried out in this 36-dimensional feature space. The resulting
test error rate was about 9.5% (see Figure 13.8). Of all the methods used
in the STATLOG project, including LVQ, CART, neural networks, linear
discriminant analysis and many others, k-nearest-neighbors performed best
on this task. Hence it is likely that the decision boundaries in IR36 are quite
irregular.

13.3.3 Invariant Metrics and Tangent Distance

In some problems, the training features are invariant under certain natural
transformations. The nearest-neighbor classiﬁer can exploit such invari-
ances by incorporating them into the metric used to measure the distances
between objects. Here we give an example where this idea was used with
great success, and the resulting classiﬁer outperformed all others at the
time of its development (Simard et al., 1993).

The problem is handwritten digit recognition, as discussed is Chapter 1
and Section 11.7. The inputs are grayscale images with 16
16 = 256
pixels; some examples are shown in Figure 13.9. At the top of Figure 13.10,
a “3” is shown, in its actual orientation (middle) and rotated 7.5◦ and 15◦
in either direction. Such rotations can often occur in real handwriting, and
it is obvious to our eye that this “3” is still a “3” after small rotations.
Hence we want our nearest-neighbor classiﬁer to consider these two “3”s
to be close together (similar). However the 256 grayscale pixel values for a
rotated “3” will look quite diﬀerent from those in the original image, and
hence the two objects can be far apart in Euclidean distance in IR256.

×

We wish to remove the eﬀect of rotation in measuring distances between
two digits of the same class. Consider the set of pixel values consisting of
the original “3” and its rotated versions. This is a one-dimensional curve in
IR256, depicted by the green curve passing through the “3” in Figure 13.10.
Figure 13.11 shows a stylized version of IR256, with two images indicated by
xi and xi′ . These might be two diﬀerent “3”s, for example. Through each
image we have drawn the curve of rotated versions of that image, called

472

13. Prototypes and Nearest-Neighbors

STATLOG results

LDA

Logistic

SMART

QDA

NewID C4.5

CART

ALLOC80

Neural

RBF

5
1
.
0

0
1
.
0

LVQ

K-NN

DANN

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

i

l

t
s
e
T

5
0
.
0

0
.
0

2

4

6

8

10

12

14

Method

FIGURE 13.8. Test-error performance for a number of classiﬁers, as reported
by the STATLOG project. The entry DANN is a variant of k-nearest neighbors,
using an adaptive metric (Section 13.4.2).

FIGURE 13.9. Examples of grayscale images of handwritten digits.

 
 
13.3 k-Nearest-Neighbor Classiﬁers

473

−15

−7.5

0

7.5

15

Transformations of 3

3

Tangent

Pixel space

a=- 0.2

a=- 0.1

a=0

a=0.1

a=0.2

Linear equation for 
images above

+ a

.

FIGURE 13.10. The top row shows a “ 3” in its original orientation (middle)
and rotated versions of it. The green curve in the middle of the ﬁgure depicts
this set of rotated “ 3” in 256-dimensional space. The red line is the tangent line
to the curve at the original image, with some “ 3”s on this tangent line, and its
equation shown at the bottom of the ﬁgure.

invariance manifolds in this context. Now, rather than using the usual
Euclidean distance between the two images, we use the shortest distance
between the two curves. In other words, the distance between the two
images is taken to be the shortest Euclidean distance between any rotated
version of ﬁrst image, and any rotated version of the second image. This
distance is called an invariant metric.

In principle one could carry out 1-nearest-neighbor classiﬁcation using
this invariant metric. However there are two problems with it. First, it is
very diﬃcult to calculate for real images. Second, it allows large trans-
formations that can lead to poor performance. For example a “6” would
be considered close to a “9” after a rotation of 180◦. We need to restrict
attention to small rotations.

The use of tangent distance solves both of these problems. As shown in
Figure 13.10, we can approximate the invariance manifold of the image
“3” by its tangent at the original image. This tangent can be computed
by estimating the direction vector from small rotations of the image, or by
more sophisticated spatial smoothing methods (Exercise 13.4.) For large
rotations, the tangent image no longer looks like a “3,” so the problem
with large transformations is alleviated.

474

13. Prototypes and Nearest-Neighbors

Transformations
of xi

Tangent distance

Distance between
transformed
xi and xi′

xi

xi′

Euclidean distance
between xi and xi′

Transformations
of xi′

FIGURE 13.11. Tangent distance computation for two images xi and xi′ .
Rather than using the Euclidean distance between xi and xi′ , or the shortest
distance between the two curves, we use the shortest distance between the two
tangent lines.

The idea then is to compute the invariant tangent line for each training
image. For a query image to be classiﬁed, we compute its invariant tangent
line, and ﬁnd the closest line to it among the lines in the training set. The
class (digit) corresponding to this closest line is our predicted class for the
query image. In Figure 13.11 the two tangent lines intersect, but this is only
because we have been forced to draw a two-dimensional representation of
the actual 256-dimensional situation. In IR256 the probability of two such
lines intersecting is eﬀectively zero.

Now a simpler way to achieve this invariance would be to add into the
training set a number of rotated versions of each training image, and then
just use a standard nearest-neighbor classiﬁer. This idea is called “hints” in
Abu-Mostafa (1995), and works well when the space of invariances is small.
So far we have presented a simpliﬁed version of the problem. In addition to
rotation, there are six other types of transformations under which we would
like our classiﬁer to be invariant. There are translation (two directions),
scaling (two directions), sheer, and character thickness. Hence the curves
and tangent lines in Figures 13.10 and 13.11 are actually 7-dimensional
manifolds and hyperplanes. It is infeasible to add transformed versions
of each training image to capture all of these possibilities. The tangent
manifolds provide an elegant way of capturing the invariances.

Table 13.1 shows the test misclassiﬁcation error for a problem with 7291
training images and 2007 test digits (the U.S. Postal Services database), for
a carefully constructed neural network, and simple 1-nearest-neighbor and

13.4 Adaptive Nearest-Neighbor Methods

475

TABLE 13.1. Test error rates for the handwritten ZIP code problem.

Method
Neural-net
1-nearest-neighbor/Euclidean distance
1-nearest-neighbor/tangent distance

Error rate
0.049
0.055
0.026

tangent distance 1-nearest-neighbor rules. The tangent distance nearest-
neighbor classiﬁer works remarkably well, with test error rates near those
for the human eye (this is a notoriously diﬃcult test set). In practice,
it turned out that nearest-neighbors are too slow for online classiﬁcation
in this application (see Section 13.5), and neural network classiﬁers were
subsequently developed to mimic it.

13.4 Adaptive Nearest-Neighbor Methods

When nearest-neighbor classiﬁcation is carried out in a high-dimensional
feature space, the nearest neighbors of a point can be very far away, causing
bias and degrading the performance of the rule.

To quantify this, consider N data points uniformly distributed in the unit
2 ]p. Let R be the radius of a 1-nearest-neighborhood centered at

1

2 , 1
cube [
the origin. Then

−

median(R) = v−1/p

p

1

1/N

1/p

,

(13.7)

1
2

−

(cid:16)
where vprp is the volume of the sphere of radius r in p dimensions. Fig-
ure 13.12 shows the median radius for various training sample sizes and
dimensions. We see that median radius quickly approaches 0.5, the dis-
tance to the edge of the cube.

(cid:17)

What can be done about this problem? Consider the two-class situation
in Figure 13.13. There are two features, and a nearest-neighborhood at
a query point is depicted by the circular region. Implicit in near-neighbor
classiﬁcation is the assumption that the class probabilities are roughly con-
stant in the neighborhood, and hence simple averages give good estimates.
However, in this example the class probabilities vary only in the horizontal
direction. If we knew this, we would stretch the neighborhood in the verti-
cal direction, as shown by the tall rectangular region. This will reduce the
bias of our estimate and leave the variance the same.

In general, this calls for adapting the metric used in nearest-neighbor
classiﬁcation, so that the resulting neighborhoods stretch out in directions
for which the class probabilities don’t change much. In high-dimensional
feature space, the class probabilities might change only a low-dimensional
subspace and hence there can be considerable advantage to adapting the
metric.

476

13. Prototypes and Nearest-Neighbors

i

s
u
d
a
R
n
a
d
e
M

i

N=1,000

N=100

N=10,000

6
.
0

5
.
0

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

0

5

10

15

Dimension

FIGURE 13.12. Median radius of a 1-nearest-neighborhood, for uniform data
with N observations in p dimensions.

5-Nearest Neighborhoods

o
o

o

o

o

o

o

o
o

•

o
o

o

o

o

o

o

o

o

o

o

o

o

o

o
o

FIGURE 13.13. The points are uniform in the cube, with the vertical line sepa-
rating class red and green. The vertical strip denotes the 5-nearest-neighbor region
using only the horizontal coordinate to ﬁnd the nearest-neighbors for the target
point (solid dot). The sphere shows the 5-nearest-neighbor region using both co-
ordinates, and we see in this case it has extended into the class-red region (and
is dominated by the wrong class in this instance).

 
13.4 Adaptive Nearest-Neighbor Methods

477

Friedman (1994a) proposed a method in which rectangular neighbor-
hoods are found adaptively by successively carving away edges of a box
containing the training data. Here we describe the discriminant adaptive
nearest-neighbor (DANN) rule of Hastie and Tibshirani (1996a). Earlier,
related proposals appear in Short and Fukunaga (1981) and Myles and
Hand (1990).

At each query point a neighborhood of say 50 points is formed, and the
class distribution among the points is used to decide how to deform the
neighborhood—that is, to adapt the metric. The adapted metric is then
used in a nearest-neighbor rule at the query point. Thus at each query
point a potentially diﬀerent metric is used.

In Figure 13.13 it is clear that the neighborhood should be stretched in
the direction orthogonal to line joining the class centroids. This direction
also coincides with the linear discriminant boundary, and is the direction
in which the class probabilities change the least. In general this direction
of maximum change will not be orthogonal to the line joining the class cen-
troids (see Figure 4.9 on page 116.) Assuming a local discriminant model,
the information contained in the local within- and between-class covari-
ance matrices is all that is needed to determine the optimal shape of the
neighborhood.

The discriminant adaptive nearest-neighbor (DANN) metric at a query

point x0 is deﬁned by

D(x, x0) = (x

x0)T Σ(x

x0),

−

−

(13.8)

where

Σ = W−1/2[W−1/2BW−1/2 + ǫI]W−1/2

= W−1/2[B∗ + ǫI]W−1/2.

(13.9)

K
Here W is the pooled within-class covariance matrix
k=1 πkWk and B
¯x)T , with
is the between class covariance matrix
¯x)(¯xk −
k=1 πk(¯xk −
P
W and B computed using only the 50 nearest neighbors around x0. After
computation of the metric, it is used in a nearest-neighbor rule at x0.

P

K

This complicated formula is actually quite simple in its operation. It ﬁrst
spheres the data with respect to W, and then stretches the neighborhood
in the zero-eigenvalue directions of B∗ (the between-matrix for the sphered
data ). This makes sense, since locally the observed class means do not dif-
fer in these directions. The ǫ parameter rounds the neighborhood, from an
inﬁnite strip to an ellipsoid, to avoid using points far away from the query
point. The value of ǫ = 1 seems to work well in general. Figure 13.14 shows
the resulting neighborhoods for a problem where the classes form two con-
centric circles. Notice how the neighborhoods stretch out orthogonally to
the decision boundaries when both classes are present in the neighborhood.
In the pure regions with only one class, the neighborhoods remain circular;

478

13. Prototypes and Nearest-Neighbors

o

o
o
o
o

o
o
o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o
o
o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o
o
o

o
o
o
o
o

o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
oo
o
oo
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

o
o

o

o

o
o

o
o
o
o

o
o

o

o

o

o

FIGURE 13.14. Neighborhoods found by the DANN procedure, at various query
points (centers of the crosses). There are two classes in the data, with one class
surrounding the other. 50 nearest-neighbors were used to estimate the local met-
rics. Shown are the resulting metrics used to form 15-nearest-neighborhoods.

in these cases the between matrix B = 0, and the Σ in (13.8) is the identity
matrix.

13.4.1 Example

Here we generate two-class data in ten dimensions, analogous to the two-
dimensional example of Figure 13.14. All ten predictors in class 1 are in-
dependent standard normal, conditioned on the radius being greater than
22.4 and less than 40, while the predictors in class 2 are independent stan-
dard normal without the restriction. There are 250 observations in each
class. Hence the ﬁrst class almost completely surrounds the second class in
the full ten-dimensional space.

In this example there are no pure noise variables, the kind that a nearest-
neighbor subset selection rule might be able to weed out. At any given
point in the feature space, the class discrimination occurs along only one
direction. However, this direction changes as we move across the feature
space and all variables are important somewhere in the space.

Figure 13.15 shows boxplots of the test error rates over ten realiza-
tions, for standard 5-nearest-neighbors, LVQ, and discriminant adaptive
5-nearest-neighbors. We used 50 prototypes per class for LVQ, to make
it comparable to 5 nearest-neighbors (since 250/5 = 50). The adaptive
metric signiﬁcantly reduces the error rate, compared to LVQ or standard
nearest-neighbors.

13.4 Adaptive Nearest-Neighbor Methods

479

r
o
r
r

E

t
s
e
T

4
0

.

3
0

.

2
0

.

1

.

0

0
0

.

5 N N

L V Q

D A N N

FIGURE 13.15. Ten-dimensional simulated example: boxplots of the test error
rates over ten realizations, for standard 5-nearest-neighbors, LVQ with 50 centers,
and discriminant-adaptive 5-nearest-neighbors

13.4.2 Global Dimension Reduction for Nearest-Neighbors

The discriminant-adaptive nearest-neighbor method carries out local di-
mension reduction—that is, dimension reduction separately at each query
point. In many problems we can also beneﬁt from global dimension re-
duction, that is, apply a nearest-neighbor rule in some optimally chosen
subspace of the original feature space. For example, suppose that the two
classes form two nested spheres in four dimensions of feature space, and
there are an additional six noise features whose distribution is independent
of class. Then we would like to discover the important four-dimensional
subspace, and carry out nearest-neighbor classiﬁcation in that reduced sub-
space. Hastie and Tibshirani (1996a) discuss a variation of the discriminant-
adaptive nearest-neighbor method for this purpose. At each training point
xi, the between-centroids sum of squares matrix Bi is computed, and then
these matrices are averaged over all training points:

¯B =

1
N

N

Bi.

(13.10)

i=1
X
Let e1, e2, . . . , ep be the eigenvectors of the matrix ¯B, ordered from largest
to smallest eigenvalue θk. Then these eigenvectors span the optimal sub-
spaces for global subspace reduction. The derivation is based on the fact
that the best rank-L approximation to ¯B, ¯B[L] =
ℓ , solves the
least squares problem

L
ℓ=1 θℓeℓeT

P

min
rank(M)=L

trace[(Bi −

M)2].

(13.11)

N

i=1
X

Since each Bi contains information on (a) the local discriminant subspace,
and (b) the strength of discrimination in that subspace, (13.11) can be seen

 
480

13. Prototypes and Nearest-Neighbors

as a way of ﬁnding the best approximating subspace of dimension L to a
series of N subspaces by weighted least squares (Exercise 13.5.)

In the four-dimensional sphere example mentioned above and examined
in Hastie and Tibshirani (1996a), four of the eigenvalues θℓ turn out to be
large (having eigenvectors nearly spanning the interesting subspace), and
the remaining six are near zero. Operationally, we project the data into
the leading four-dimensional subspace, and then carry out nearest neighbor
classiﬁcation. In the satellite image classiﬁcation example in Section 13.3.2,
the technique labeled DANN in Figure 13.8 used 5-nearest-neighbors in a
globally reduced subspace. There are also connections of this technique
with the sliced inverse regression proposal of Duan and Li (1991). These
authors use similar ideas in the regression setting, but do global rather
than local computations. They assume and exploit spherical symmetry of
the feature distribution to estimate interesting subspaces.

13.5 Computational Considerations

One drawback of nearest-neighbor rules in general is the computational
load, both in ﬁnding the neighbors and storing the entire training set. With
N observations and p predictors, nearest-neighbor classiﬁcation requires N p
operations to ﬁnd the neighbors per query point. There are fast algorithms
for ﬁnding nearest-neighbors (Friedman et al., 1975; Friedman et al., 1977)
which can reduce this load somewhat. Hastie and Simard (1998) reduce
the computations for tangent distance by developing analogs of K-means
clustering in the context of this invariant metric.

Reducing the storage requirements is more diﬃcult, and various editing
and condensing procedures have been proposed. The idea is to isolate a
subset of the training set that suﬃces for nearest-neighbor predictions, and
throw away the remaining training data. Intuitively, it seems important to
keep the training points that are near the decision boundaries and on the
correct side of those boundaries, while some points far from the boundaries
could be discarded.

The multi-edit algorithm of Devijver and Kittler (1982) divides the data
cyclically into training and test sets, computing a nearest neighbor rule on
the training set and deleting test points that are misclassiﬁed. The idea is
to keep homogeneous clusters of training observations.

The condensing procedure of Hart (1968) goes further, trying to keep
only important exterior points of these clusters. Starting with a single ran-
domly chosen observation as the training set, each additional data item is
processed one at a time, adding it to the training set only if it is misclas-
siﬁed by a nearest-neighbor rule computed on the current training set.

These procedures are surveyed in Dasarathy (1991) and Ripley (1996).
They can also be applied to other learning procedures besides nearest-

neighbors. While such methods are sometimes useful, we have not had
much practical experience with them, nor have we found any systematic
comparison of their performance in the literature.

Exercises

481

Bibliographic Notes

The nearest-neighbor method goes back at least to Fix and Hodges (1951).
The extensive literature on the topic is reviewed by Dasarathy (1991);
Chapter 6 of Ripley (1996) contains a good summary. K-means cluster-
ing is due to Lloyd (1957) and MacQueen (1967). Kohonen (1989) intro-
duced learning vector quantization. The tangent distance method is due to
Simard et al. (1993). Hastie and Tibshirani (1996a) proposed the discrim-
inant adaptive nearest-neighbor technique.

Exercises

Ex. 13.1 Consider a Gaussian mixture model where the covariance matrices
are assumed to be scalar: Σr = σI
r = 1, . . . , R, and σ is a ﬁxed param-
∀
eter. Discuss the analogy between the K-means clustering algorithm and
the EM algorithm for ﬁtting this mixture model in detail. Show that in the
limit σ

0 the two methods coincide.

→

Ex. 13.2 Derive formula (13.7) for the median radius of the 1-nearest-
neighborhood.

Ex. 13.3 Let E∗ be the error rate of the Bayes rule in a K-class problem,
where the true class probabilities are given by pk(x), k = 1, . . . , K. As-
suming the test point and training point have identical features x, prove
(13.5)

K

Xk=1

pk(x)(1

pk(x))

2(1

−

≤

−

pk∗(x))

−

K

K

−

(1

1

−

pk∗(x))2.

where k∗ = arg maxk pk(x). Hence argue that the error rate of the 1-
nearest-neighbor rule converges in L1, as the size of the training set in-
creases, to a value E1, bounded above by

E∗

2

(cid:16)

E∗ K
K
−

−

.

1

(cid:17)

(13.12)

[This statement of the theorem of Cover and Hart (1967) is taken from
Chapter 6 of Ripley (1996), where a short proof is also given].

482

13. Prototypes and Nearest-Neighbors

Ex. 13.4 Consider an image to be a function F (x) : IR2
dimensional spatial domain (paper coordinates). Then F (c+x0+A(x
−
represents an aﬃne transformation of the image F , where A is a 2
matrix.

IR1 over the two-
x0))
2

7→

×

1. Decompose A (via Q-R) in such a way that parameters identifying
the four aﬃne transformations (two scale, shear and rotation) are
clearly identiﬁed.

2. Using the chain rule, show that the derivative of F (c+x0 +A(x

x0))
w.r.t. each of these parameters can be represented in terms of the two
spatial derivatives of F .

−

3. Using a two-dimensional kernel smoother (Chapter 6), describe how
to implement this procedure when the images are quantized to 16
16
pixels.

×

Ex. 13.5 Let Bi, i = 1, 2, . . . , N be square p
trices and let ¯B = (1/N )

p positive semi-deﬁnite ma-
Bi. Write the eigen-decomposition of ¯B as
θ1. Show that the best rank-L approx-

×

p
ℓ=1 θℓeℓeT

ℓ with θℓ ≥

θℓ−1 ≥ · · · ≥
P

imation for the Bi,
P

is given by ¯B[L] =

N

min
rank(M)=L

trace[(Bi −

M)2],

N

i=1
X

L
ℓ=1 θℓeℓeT

ℓ . (Hint: Write

N

i=1 trace[(Bi −

M)2] as

P
trace[(Bi −

¯B)2] +

N

P
trace[(M

¯B)2]).

−

i=1
X

i=1
X

Ex. 13.6 Here we consider the problem of shape averaging. In particular,
2 matrices of points in IR2, each sampled
Li, i = 1, . . . , M are each N
from corresponding positions of handwritten (cursive) letters. We seek an
2, VT V = I, of the M letters Li with
aﬃne invariant average V, also N
×
the following property: V minimizes

×

M

j=1
X

min
Aj k

Lj −

VAjk

2 .

Characterize the solution.

This solution can suﬀer if some of the letters are big and dominate the

average. An alternative approach is to minimize instead:

M

j=1
X

min
Aj

LjA∗

j −

V

2

.

(cid:13)
(cid:13)

(cid:13)
(cid:13)

Derive the solution to this problem. How do the criteria diﬀer? Use the
SVD of the Lj to simplify the comparison of the two approaches.

Exercises

483

Ex. 13.7 Consider the application of nearest-neighbors to the “easy” and
“hard” problems in the left panel of Figure 13.5.

1. Replicate the results in the left panel of Figure 13.5.

2. Estimate the misclassiﬁcation errors using ﬁvefold cross-validation,

and compare the error rate curves to those in 1.

3. Consider an “AIC-like” penalization of the training set misclassiﬁca-
tion error. Speciﬁcally, add 2t/N to the training set misclassiﬁcation
error, where t is the approximate number of parameters N/r, r be-
ing the number of nearest-neighbors. Compare plots of the resulting
penalized misclassiﬁcation error to those in 1 and 2. Which method
gives a better estimate of the optimal number of nearest-neighbors:
cross-validation or AIC?

Ex. 13.8 Generate data in two classes, with two features. These features
are all independent Gaussian variates with standard deviation 1. Their
mean vectors are (
1) in class 1 and (1, 1) in class 2. To each feature
vector apply a random rotation of angle θ, θ chosen uniformly from 0 to
2π. Generate 50 observations from each class to form the training set, and
500 in each class as the test set. Apply four diﬀerent classiﬁers:

−

−

1,

1. Nearest-neighbors.

2. Nearest-neighbors with hints: ten randomly rotated versions of each
data point are added to the training set before applying nearest-
neighbors.

3. Invariant metric nearest-neighbors, using Euclidean distance invari-

ant to rotations about the origin.

4. Tangent distance nearest-neighbors.

In each case choose the number of neighbors by tenfold cross-validation.
Compare the results.

484

13. Prototypes and Nearest-Neighbors

14
Unsupervised Learning

This is page 485
Printer: Opaque this

14.1

Introduction

The previous chapters have been concerned with predicting the values
of one or more outputs or response variables Y = (Y1, . . . , Ym) for a
given set of input or predictor variables X T = (X1, . . . , Xp). Denote by
xT
i = (xi1, . . . , xip) the inputs for the ith training case, and let yi be a
response measurement. The predictions are based on the training sample
(x1, y1), . . . , (xN , yN ) of previously solved cases, where the joint values of
all of the variables are known. This is called supervised learning or “learn-
ing with a teacher.” Under this metaphor the “student” presents an an-
swer ˆyi for each xi in the training sample, and the supervisor or “teacher”
provides either the correct answer and/or an error associated with the stu-
dent’s answer. This is usually characterized by some loss function L(y, ˆy),
for example, L(y, ˆy) = (y

ˆy)2.

If one supposes that (X, Y ) are random variables represented by some
joint probability density Pr(X, Y ), then supervised learning can be formally
characterized as a density estimation problem where one is concerned with
determining properties of the conditional density Pr(Y
X). Usually the
properties of interest are the “location” parameters µ that minimize the
expected error at each x,

|

−

µ(x) = argmin

θ

EY |X L(Y, θ).

(14.1)

486

14. Unsupervised Learning

Conditioning one has

Pr(X, Y ) = Pr(Y

X)

|

·

Pr(X),

where Pr(X) is the joint marginal density of the X values alone. In su-
pervised learning Pr(X) is typically of no direct concern. One is interested
mainly in the properties of the conditional density Pr(Y
X). Since Y is of-
ten of low dimension (usually one), and only its location µ(x) is of interest,
the problem is greatly simpliﬁed. As discussed in the previous chapters,
there are many approaches for successfully addressing supervised learning
in a variety of contexts.

|

In this chapter we address unsupervised learning or “learning without a
teacher.” In this case one has a set of N observations (x1, x2, . . . , xN ) of a
random p-vector X having joint density Pr(X). The goal is to directly infer
the properties of this probability density without the help of a supervisor or
teacher providing correct answers or degree-of-error for each observation.
The dimension of X is sometimes much higher than in supervised learn-
ing, and the properties of interest are often more complicated than simple
location estimates. These factors are somewhat mitigated by the fact that
X represents all of the variables under consideration; one is not required
to infer how the properties of Pr(X) change, conditioned on the changing
values of another set of variables.

In low-dimensional problems (say p

3), there are a variety of eﬀective
nonparametric methods for directly estimating the density Pr(X) itself at
all X-values, and representing it graphically (Silverman, 1986, e.g.). Owing
to the curse of dimensionality, these methods fail in high dimensions. One
must settle for estimating rather crude global models, such as Gaussian
mixtures or various simple descriptive statistics that characterize Pr(X).

≤

Generally, these descriptive statistics attempt to characterize X-values,
or collections of such values, where Pr(X) is relatively large. Principal
components, multidimensional scaling, self-organizing maps, and principal
curves, for example, attempt to identify low-dimensional manifolds within
the X-space that represent high data density. This provides information
about the associations among the variables and whether or not they can be
considered as functions of a smaller set of “latent” variables. Cluster anal-
ysis attempts to ﬁnd multiple convex regions of the X-space that contain
modes of Pr(X). This can tell whether or not Pr(X) can be represented by
a mixture of simpler densities representing distinct types or classes of ob-
servations. Mixture modeling has a similar goal. Association rules attempt
to construct simple descriptions (conjunctive rules) that describe regions
of high density in the special case of very high dimensional binary-valued
data.

With supervised learning there is a clear measure of success, or lack
thereof, that can be used to judge adequacy in particular situations and
to compare the eﬀectiveness of diﬀerent methods over various situations.

14.2 Association Rules

487

Lack of success is directly measured by expected loss over the joint dis-
tribution Pr(X, Y ). This can be estimated in a variety of ways including
cross-validation. In the context of unsupervised learning, there is no such
direct measure of success. It is diﬃcult to ascertain the validity of inferences
drawn from the output of most unsupervised learning algorithms. One must
resort to heuristic arguments not only for motivating the algorithms, as is
often the case in supervised learning as well, but also for judgments as to
the quality of the results. This uncomfortable situation has led to heavy
proliferation of proposed methods, since eﬀectiveness is a matter of opinion
and cannot be veriﬁed directly.

In this chapter we present those unsupervised learning techniques that
are among the most commonly used in practice, and additionally, a few
others that are favored by the authors.

14.2 Association Rules

Association rule analysis has emerged as a popular tool for mining com-
mercial data bases. The goal is to ﬁnd joint values of the variables X =
(X1, X2, . . . , Xp) that appear most frequently in the data base. It is most
, where it is referred to as
0, 1
often applied to binary-valued data Xj ∈ {
}
“market basket” analysis. In this context the observations are sales trans-
actions, such as those occurring at the checkout counter of a store. The
variables represent all of the items sold in the store. For observation i, each
variable Xj is assigned one of two values; xij = 1 if the jth item is pur-
chased as part of the transaction, whereas xij = 0 if it was not purchased.
Those variables that frequently have joint values of one represent items that
are frequently purchased together. This information can be quite useful for
stocking shelves, cross-marketing in sales promotions, catalog design, and
consumer segmentation based on buying patterns.

More generally, the basic goal of association rule analysis is to ﬁnd a
collection of prototype X-values v1, . . . , vL for the feature vector X, such
that the probability density Pr(vl) evaluated at each of those values is rela-
tively large. In this general framework, the problem can be viewed as “mode
ﬁnding” or “bump hunting.” As formulated, this problem is impossibly dif-
ﬁcult. A natural estimator for each Pr(vl) is the fraction of observations
for which X = vl. For problems that involve more than a small number
of variables, each of which can assume more than a small number of val-
ues, the number of observations for which X = vl will nearly always be too
small for reliable estimation. In order to have a tractable problem, both the
goals of the analysis and the generality of the data to which it is applied
must be greatly simpliﬁed.

The ﬁrst simpliﬁcation modiﬁes the goal. Instead of seeking values x
where Pr(x) is large, one seeks regions of the X-space with high probability

488

14. Unsupervised Learning

Sj represent the set of all
content relative to their size or support. Let
possible values of the jth variable (its support), and let sj ⊆ Sj be a subset
of these values. The modiﬁed goal can be stated as attempting to ﬁnd
subsets of variable values s1, . . . , sp such that the probability of each of the
variables simultaneously assuming a value within its respective subset,

p

Pr



(Xj ∈

sj)

,



(14.2)

j=1
\




is relatively large. The intersection of subsets
sj) is called a
conjunctive rule. For quantitative variables the subsets sj are contiguous
intervals; for categorical variables the subsets are delineated explicitly. Note
that if the subset sj is in fact the entire set of values sj =
Sj, as is often
the case, the variable Xj is said not to appear in the rule (14.2).

j=1(Xj ∈

∩

p

14.2.1 Market Basket Analysis

≈

104, N

General approaches to solving (14.2) are discussed in Section 14.2.5. These
can be quite useful in many applications. However, they are not feasible
108) commercial data bases to which
for the very large (p
market basket analysis is often applied. Several further simpliﬁcations of
(14.2) are required. First, only two types of subsets are considered; either
sj consists of a single value of Xj, sj = v0j, or it consists of the entire set
of values that Xj can assume, sj =
Sj. This simpliﬁes the problem (14.2)
to ﬁnding subsets of the integers
, and corresponding values
}
, such that
v0j, j

1, . . . , p

J ⊂ {

≈

∈ J


is large. Figure 14.1 illustrates this assumption.



Pr



(Xj = v0j)



(14.3)

\j∈J

One can apply the technique of dummy variables to turn (14.3) into
a problem involving only binary-valued variables. Here we assume that
the support
Sj is ﬁnite for each variable Xj. Speciﬁcally, a new set of
variables Z1, . . . , ZK is created, one such variable for each of the values
vlj attainable by each of the original variables X1, . . . , Xp. The number of
dummy variables K is

p

K =

,

|Sj|

j=1
X

|Sj|

where
is the number of distinct values attainable by Xj. Each dummy
variable is assigned the value Zk = 1 if the variable with which it is as-
sociated takes on the corresponding value to which Zk is assigned, and
Zk = 0 otherwise. This transforms (14.3) to ﬁnding a subset of the integers

1, . . . , K

K ⊂ {

such that

}

14.2 Association Rules

489

2
X

2
X

2
X

X1

X1

X1

FIGURE 14.1. Simpliﬁcations for association rules. Here there are two inputs
X1 and X2, taking four and six distinct values, respectively. The red squares
indicate areas of high density. To simplify the computations, we assume that the
derived subset corresponds to either a single value of an input or all values. With
this assumption we could ﬁnd either the middle or right pattern, but not the left
one.

Pr

"
\k∈K

(Zk = 1)

= Pr

#

"
Yk∈K

Zk = 1

#

(14.4)

is large. This is the standard formulation of the market basket problem.
is called an “item set.” The number of variables Zk in the item
The set
set is called its “size” (note that the size is no bigger than p). The estimated
value of (14.4) is taken to be the fraction of observations in the data base
for which the conjunction in (14.4) is true:

K

(Zk = 1)

1
N

=

#

"

Yk∈K

N

i=1
X

Yk∈K

zik.

(14.5)

Pr

c

Here zik is the value of Zk for this ith case. This is called the “support” or
k∈K zik =
“prevalence” T (
K
K
1 is said to “contain” the item set

. An observation i for which

) of the item set

.

In association rule mining a lower support bound t is speciﬁed, and one
Kl that can be formed from the variables Z1, . . . , ZK

seeks all item sets
with support in the data base greater than this lower bound t

Q

K

{Kl|

T (

Kl) > t

.
}

(14.6)

14.2.2 The Apriori Algorithm

The solution to this problem (14.6) can be obtained with feasible compu-
tation for very large data bases provided the threshold t is adjusted so that
(14.6) consists of only a small fraction of all 2K possible item sets. The
“Apriori” algorithm (Agrawal et al., 1995) exploits several aspects of the

490

14. Unsupervised Learning

curse of dimensionality to solve (14.6) with a small number of passes over
the data. Speciﬁcally, for a given support threshold t:

•

•

The cardinality

T (

) > t

is relatively small.

K

|{K|
consisting of a subset of the items in

}|

Any item set
support greater than or equal to that of

L

,

K

L ⊆ K ⇒

must have
).
T (
)

≥

K

K
T (
L

|K|

The ﬁrst pass over the data computes the support of all single-item sets.
Those whose support is less than the threshold are discarded. The second
pass computes the support of all item sets of size two that can be formed
from pairs of the single items surviving the ﬁrst pass. In other words, to
= m, we need to consider only
generate all frequent itemsets with
candidates such that all of their m ancestral item sets of size m
1 are
frequent. Those size-two item sets with support less than the threshold are
discarded. Each successive pass over the data considers only those item
sets that can be formed by combining those that survived the previous
pass with those retained from the ﬁrst pass. Passes over the data continue
until all candidate rules from the previous pass have support less than the
speciﬁed threshold. The Apriori algorithm requires only one pass over the
data for each value of
, which is crucial since we assume the data cannot
be ﬁtted into a computer’s main memory. If the data are suﬃciently sparse
(or if the threshold t is high enough), then the process will terminate in
reasonable time even for huge data sets.

|K|

−

There are many additional tricks that can be used as part of this strat-
egy to increase speed and convergence (Agrawal et al., 1995). The Apriori
algorithm represents one of the major advances in data mining technology.
(14.6) returned by the Apriori algorithm is
, are partitioned

cast into a set of “association rules.” The items Zk, k
into two disjoint subsets, A

Each high support item set

, and written

B =

∈ K

K

∪

K

A

B.

(14.7)

⇒
The ﬁrst item subset A is called the “antecedent” and the second B the
“consequent.” Association rules are deﬁned to have several properties based
on the prevalence of the antecedent and consequent item sets in the data
base. The “support” of the rule T (A
B) is the fraction of observations
in the union of the antecedent and consequent, which is just the support
of the item set
from which they were derived. It can be viewed as an
estimate (14.5) of the probability of simultaneously observing both item
sets Pr(A and B) in a randomly selected market basket. The “conﬁdence”
B) of the rule is its support divided by the
or “predictability” C(A
support of the antecedent

⇒

⇒

K

C(A

⇒

B) =

T (A

B)

⇒
T (A)

,

(14.8)

A). The notation Pr(A), the
which can be viewed as an estimate of Pr(B
probability of an item set A occurring in a basket, is an abbreviation for

|

14.2 Association Rules

491

Pr(
k∈A Zk = 1). The “expected conﬁdence” is deﬁned as the support of
the consequent T (B), which is an estimate of the unconditional probability
Pr(B). Finally, the “lift” of the rule is deﬁned as the conﬁdence divided by
the expected conﬁdence

Q

L(A

⇒

B) =

C(A

⇒
T (B)

B)

.

K

=

} ⇒ {

As an example, suppose the item set

This is an estimate of the association measure Pr(A and B)/Pr(A)Pr(B).
peanut butter, jelly, bread
}
{
. A support value
and consider the rule
bread
peanut butter, jelly
}
{
of 0.03 for this rule means that peanut butter, jelly, and bread appeared
together in 3% of the market baskets. A conﬁdence of 0.82 for this rule im-
plies that when peanut butter and jelly were purchased, 82% of the time
bread was also purchased. If bread appeared in 43% of all market baskets
would have a lift of 1.95.
then the rule
} ⇒ {
The goal of this analysis is to produce association rules (14.7) with both
high values of support and conﬁdence (14.8). The Apriori algorithm returns
all item sets with high support as deﬁned by the support threshold t (14.6).
A conﬁdence threshold c is set, and all rules that can be formed from those
item sets (14.6) with conﬁdence greater than this value

peanut butter, jelly
{

bread
}

A
{

B

|

⇒

C(A

⇒
of size

B) > c

}

(14.9)

there are 2|K|−1
1 rules of
are reported. For each item set
the form A
. Agrawal et al. (1995) present a variant of
(
the Apriori algorithm that can rapidly determine which rules survive the
conﬁdence threshold (14.9) from all possible rules that can be formed from
the solution item sets (14.6).

A), A

⊂ K

K −

|K|

⇒

−

K

The output of the entire analysis is a collection of association rules (14.7)

that satisfy the constraints

T (A

⇒

B) > t

and C(A

B) > c.

⇒

These are generally stored in a data base that can be queried by the user.
Typical requests might be to display the rules in sorted order of conﬁdence,
lift or support. More speciﬁcally, one might request such a list conditioned
on particular items in the antecedent or especially the consequent. For
example, a request might be the following:

Display all transactions in which ice skates are the consequent
that have conﬁdence over 80% and support of more than 2%.

This could provide information on those items (antecedent) that predicate
sales of ice skates. Focusing on a particular consequent casts the problem
into the framework of supervised learning.

Association rules have become a popular tool for analyzing very large
commercial data bases in settings where market basket is relevant. That is

492

14. Unsupervised Learning

when the data can be cast in the form of a multidimensional contingency
table. The output is in the form of conjunctive rules (14.4) that are easily
understood and interpreted. The Apriori algorithm allows this analysis to
be applied to huge data bases, much larger that are amenable to other types
of analyses. Association rules are among data mining’s biggest successes.

Besides the restrictive form of the data to which they can be applied, as-
sociation rules have other limitations. Critical to computational feasibility
is the support threshold (14.6). The number of solution item sets, their size,
and the number of passes required over the data can grow exponentially
with decreasing size of this lower bound. Thus, rules with high conﬁdence
or lift, but low support, will not be discovered. For example, a high conﬁ-
dence rule such as vodka
caviar will not be uncovered owing to the low
sales volume of the consequent caviar.

⇒

14.2.3 Example: Market Basket Analysis

We illustrate the use of Apriori on a moderately sized demographics data
base. This data set consists of N = 9409 questionnaires ﬁlled out by shop-
ping mall customers in the San Francisco Bay Area (Impact Resources, Inc.,
Columbus OH, 1987). Here we use answers to the ﬁrst 14 questions, relat-
ing to demographics, for illustration. These questions are listed in Table
14.1. The data are seen to consist of a mixture of ordinal and (unordered)
categorical variables, many of the latter having more than a few values.
There are many missing values.

We used a freeware implementation of the Apriori algorithm due to Chris-
tian Borgelt1. After removing observations with missing values, each ordinal
predictor was cut at its median and coded by two dummy variables; each
categorical predictor with k categories was coded by k dummy variables.
This resulted in a 6876
50 matrix of 6876 observations on 50 dummy
variables.

×

The algorithm found a total of 6288 association rules, involving

5
predictors, with support of at least 10%. Understanding this large set of
rules is itself a challenging data analysis task. We will not attempt this here,
but only illustrate in Figure 14.2 the relative frequency of each dummy
variable in the data (top) and the association rules (bottom). Prevalent
categories tend to appear more often in the rules, for example, the ﬁrst
category in language (English). However, others such as occupation are
under-represented, with the exception of the ﬁrst and ﬁfth level.

≤

Here are three examples of association rules found by the Apriori algo-

rithm:

Association rule 1: Support 25%, conﬁdence 99.7% and lift 1.03.

1See http://fuzzy.cs.uni-magdeburg.de/∼borgelt.

b
y

t
h
e
A
p
r
i
o
r
i

a
l
g
o
r
i
t
h
m

(
b
o
t
t
o
m

)
.

a
b
l
e

(
c
o
d
i
n
g

a
n

i
n
p
u
t

c
a
t
e
g
o
r
y
)

i
n

t
h
e

d
a
t
a

(
t
o
p
)
,

a
n
d

t
h
e

a
s
s
o
c
i
a
t
i
o
n

r
u
l
e
s

f
o
u
n
d

F
I
G
U
R
E

1
4
.
2
.

M
a
r
k
e
t

b
a
s
k
e
t

a
n
a
l
y
s
i
s
:

r
e
l
a
t
i
v
e

f
r
e
q
u
e
n
c
y

o
f

e
a
c
h

d
u
m
m
y

v
a
r
i
-

Relative Frequency in Association Rules

Relative Frequency in Data

0.0

0.04

0.08

0.12

0.0

0.02

0.04

0.06

A

t
t
r
i
b
u
t
e

0

1
0

2
0

3
0

4
0

5
0

income

sex

marstat

age

educ

occup

yrs−bay

dualinc

perhous

peryoung

house

typehome

ethnic

language

A

t
t
r
i
b
u
t
e

0

1
0

2
0

3
0

4
0

5
0

income

sex

marstat

age

educ

occup

yrs−bay

dualinc

perhous

peryoung

house

typehome

ethnic

language

1
4
.
2
A
s
s
o
c
i
a
t
i
o
n
R
u
l
e
s

4
9
3

494

14. Unsupervised Learning

TABLE 14.1. Inputs for the demographic data.

Feature Demographic

# Values Type

1
2
3
4
5
6
7
8
9
10
11
12
13
14

Sex
Marital status
Age
Education
Occupation
Income
Years in Bay Area
Dual incomes
Number in household
Number of children
Householder status
Type of home
Ethnic classiﬁcation
Language in home

2
5
7
6
9
9
5
3
9
9
3
5
8
3

Categorical
Categorical
Ordinal
Ordinal
Categorical
Ordinal
Ordinal
Categorical
Ordinal
Ordinal
Categorical
Categorical
Categorical
Categorical

number in household = 1
number of children = 0

(cid:20)

(cid:21)

⇓
language in home = English

Association rule 2: Support 13.4%, conﬁdence 80.8%, and lift 2.13.





language in home = English
householder status = own
occupation =

professional/managerial
{
⇓
≥

$40,000





}

income

Association rule 3: Support 26.5%, conﬁdence 82.8% and lift 2.15.

language in home = English
income < $40,000

marital status = not married

number of children = 0













education /

college graduate, graduate study
}

∈ {

⇓

14.2 Association Rules

495

We chose the ﬁrst and third rules based on their high support. The second
rule is an association rule with a high-income consequent, and could be
used to try to target high-income individuals.

As stated above, we created dummy variables for each category of the
input predictors, for example, Z1 = I(income < $40, 000) and Z2 =
$40, 000) for below and above the median income. If we were
I(income
interested only in ﬁnding associations with the high-income category, we
would include Z2 but not Z1. This is often the case in actual market basket
problems, where we are interested in ﬁnding associations with the presence
of a relatively rare item, but not associations with its absence.

≥

14.2.4 Unsupervised as Supervised Learning

Here we discuss a technique for transforming the density estimation prob-
lem into one of supervised function approximation. This forms the basis
for the generalized association rules described in the next section.

Let g(x) be the unknown data probability density to be estimated, and
g0(x) be a speciﬁed probability density function used for reference. For ex-
ample, g0(x) might be the uniform density over the range of the variables.
Other possibilities are discussed below. The data set x1, x2, . . . , xN is pre-
sumed to be an i.i.d. random sample drawn from g(x). A sample of size N0
can be drawn from g0(x) using Monte Carlo methods. Pooling these two
data sets, and assigning mass w = N0/(N + N0) to those drawn from g(x),
and w0 = N/(N + N0) to those drawn from g0(x), results in a random
sample drawn from the mixture density (g(x) + g0(x)) /2. If one assigns
the value Y = 1 to each sample point drawn from g(x) and Y = 0 those
drawn from g0(x), then

µ(x) = E(Y

x) =

|

=

g(x)
g(x) + g0(x)
g(x)/g0(x)
1 + g(x)/g0(x)

(14.10)

can be estimated by supervised learning using the combined sample

(y1, x1), (y2, x2), . . . , (yN +N0 , xN +N0 )

(14.11)

as training data. The resulting estimate ˆµ(x) can be inverted to provide an
estimate for g(x)

ˆg(x) = g0(x)

1

ˆµ(x)

ˆµ(x)

−

.

(14.12)

Generalized versions of logistic regression (Section 4.4) are especially well

suited for this application since the log-odds,

f (x) = log

g(x)
g0(x)

,

(14.13)

are estimated directly. In this case one has

496

14. Unsupervised Learning

2
X

•

•
•

•
•
•

6

4

2

0

2
-

•

•
•
•

•
•

•

•

•

•

2
X

•
•
•
•
•
•
•
•
•
•
•
•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•

6

4

2

0

2
-

•
•
•

•

•

•

•

•

•
•

•
•

•
•

••

•
•
•

•
•
•

•
•
•
•

•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•

•
•

•
•

•

•

•

•

•
•
•
•
•
•
•
•
•

•

•
•
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•
•
•
•

•
•
•

•
•
•
•
•

•
•
•
•
•

•
•

•
•
•
•

-1

0

1

2

-1

0

1

2

X1

X1

FIGURE 14.3. Density estimation via classiﬁcation. (Left panel:) Training set
of 200 data points. (Right panel:) Training set plus 200 reference data points,
generated uniformly over the rectangle containing the training data. The training
sample was labeled as class 1, and the reference sample class 0, and a semipara-
metric logistic regression model was ﬁt to the data. Some contours for ˆg(x) are
shown.

ˆg(x) = g0(x) e

ˆf (x).

(14.14)

An example is shown in Figure 14.3. We generated a training set of size
200 shown in the left panel. The right panel shows the reference data (blue)
generated uniformly over the rectangle containing the training data. The
training sample was labeled as class 1, and the reference sample class 0,
and a logistic regression model, using a tensor product of natural splines
(Section 5.2.1), was ﬁt to the data. Some probability contours of ˆµ(x) are
shown in the right panel; these are also the contours of the density estimate
ˆg(x), since ˆg(x) = ˆµ(x)/(1
ˆµ(x)), is a monotone function. The contours
roughly capture the data density.

−

In principle any reference density can be used for g0(x) in (14.14). In
practice the accuracy of the estimate ˆg(x) can depend greatly on partic-
ular choices. Good choices will depend on the data density g(x) and the
procedure used to estimate (14.10) or (14.13). If accuracy is the goal, g0(x)
should be chosen so that the resulting functions µ(x) or f (x) are approx-
imated easily by the method being used. However, accuracy is not always
the primary goal. Both µ(x) and f (x) are monotonic functions of the den-
sity ratio g(x)/g0(x). They can thus be viewed as “contrast” statistics that
provide information concerning departures of the data density g(x) from
the chosen reference density g0(x). Therefore, in data analytic settings, a
choice for g0(x) is dictated by types of departures that are deemed most
interesting in the context of the speciﬁc problem at hand. For example, if
departures from uniformity are of interest, g0(x) might be the a uniform
density over the range of the variables. If departures from joint normality

14.2 Association Rules

497

are of interest, a good choice for g0(x) would be a Gaussian distribution
with the same mean vector and covariance matrix as the data. Departures
from independence could be investigated by using

p

g0(x) =

gj(xj),

(14.15)

j=1
Y
where gj(xj) is the marginal data density of Xj, the jth coordinate of X.
A sample from this independent density (14.15) is easily generated from the
data itself by applying a diﬀerent random permutation to the data values
of each of the variables.

As discussed above, unsupervised learning is concerned with revealing
properties of the data density g(x). Each technique focuses on a particu-
lar property or set of properties. Although this approach of transforming
the problem to one of supervised learning (14.10)–(14.14) seems to have
been part of the statistics folklore for some time, it does not appear to
have had much impact despite its potential to bring well-developed su-
pervised learning methodology to bear on unsupervised learning problems.
One reason may be that the problem must be enlarged with a simulated
data set generated by Monte Carlo techniques. Since the size of this data
N , the compu-
set should be at least as large as the data sample N0 ≥
tation and memory requirements of the estimation procedure are at least
doubled. Also, substantial computation may be required to generate the
Monte Carlo sample itself. Although perhaps a deterrent in the past, these
increased computational requirements are becoming much less of a burden
as increased resources become routinely available. We illustrate the use of
supervising learning methods for unsupervised learning in the next section.

14.2.5 Generalized Association Rules

The more general problem (14.2) of ﬁnding high-density regions in the data
space can be addressed using the supervised learning approach described
above. Although not applicable to the huge data bases for which market
basket analysis is feasible, useful information can be obtained from mod-
erately sized data sets. The problem (14.2) can be formulated as ﬁnding
subsets of the integers
and corresponding value subsets
sj, j

for the corresponding variables Xj, such that

1, 2, . . . , p

J ⊂ {

}

∈ J

Pr



c



\j∈J

(Xj ∈

sj)



=

1
N

N

I

i=1
X





\j∈J



(xij ∈

sj)



(14.16)



(Xj ∈
is large. Following the nomenclature of association rule analysis,
{
}j∈J will be called a “generalized” item set. The subsets sj correspond-
sj)
ing to quantitative variables are taken to be contiguous intervals within

498

14. Unsupervised Learning

their range of values, and subsets for categorical variables can involve more
than a single value. The ambitious nature of this formulation precludes a
thorough search for all generalized item sets with support (14.16) greater
than a speciﬁed minimum threshold, as was possible in the more restric-
tive setting of market basket analysis. Heuristic search methods must be
employed, and the most one can hope for is to ﬁnd a useful collection of
such generalized item sets.

Both market basket analysis (14.5) and the generalized formulation (14.16)

implicitly reference the uniform probability distribution. One seeks item
sets that are more frequent than would be expected if all joint data values
(x1, x2, . . . , xN ) were uniformly distributed. This favors the discovery of
sj) are individually frequent,
item sets whose marginal constituents (Xj ∈
that is, the quantity

1
N

N

i=1
X

I(xij ∈

sj)

(14.17)

is large. Conjunctions of frequent subsets (14.17) will tend to appear more
often among item sets of high support (14.16) than conjunctions of margin-
ally less frequent subsets. This is why the rule vodka
caviar is not likely
to be discovered in spite of a high association (lift); neither item has high
marginal support, so that their joint support is especially small. Reference
to the uniform distribution can cause highly frequent item sets with low
associations among their constituents to dominate the collection of highest
support item sets.

⇒

Highly frequent subsets sj are formed as disjunctions of the most fre-
quent Xj-values. Using the product of the variable marginal data densities
(14.15) as a reference distribution removes the preference for highly fre-
quent values of the individual variables in the discovered item sets. This is
because the density ratio g(x)/g0(x) is uniform if there are no associations
among the variables (complete independence), regardless of the frequency
distribution of the individual variable values. Rules like vodka
caviar
would have a chance to emerge. It is not clear however, how to incorporate
reference distributions other than the uniform into the Apriori algorithm.
As explained in Section 14.2.4, it is straightforward to generate a sample
from the product density (14.15), given the original data set.

⇒

After choosing a reference distribution, and drawing a sample from it
as in (14.11), one has a supervised learning problem with a binary-valued
output variable Y
. The goal is to use this training data to ﬁnd
0, 1
}
regions

∈ {

R =

\j∈J

(Xj ∈

sj)

(14.18)

for which the target function µ(x) = E(Y
one might wish to require that the data support of these regions

x) is relatively large. In addition,

|

14.2 Association Rules

499

T (R) =

g(x) dx

(14.19)

Zx∈R

not be too small.

14.2.6 Choice of Supervised Learning Method

The regions (14.18) are deﬁned by conjunctive rules. Hence supervised
methods that learn such rules would be most appropriate in this context.
The terminal nodes of a CART decision tree are deﬁned by rules precisely
of the form (14.18). Applying CART to the pooled data (14.11) will pro-
duce a decision tree that attempts to model the target (14.10) over the
entire data space by a disjoint set of regions (terminal nodes). Each region
is deﬁned by a rule of the form (14.18). Those terminal nodes t with high
average y-values

¯yt = ave(yi |

xi ∈

t)

are candidates for high-support generalized item sets (14.16). The actual
(data) support is given by

T (R) = ¯yt ·

Nt
N + N0

,

where Nt is the number of (pooled) observations within the region repre-
sented by the terminal node. By examining the resulting decision tree, one
might discover interesting generalized item sets of relatively high-support.
These can then be partitioned into antecedents and consequents in a search
for generalized association rules of high conﬁdence and/or lift.

Another natural learning method for this purpose is the patient rule
induction method PRIM described in Section 9.3. PRIM also produces
rules precisely of the form (14.18), but it is especially designed for ﬁnding
high-support regions that maximize the average target (14.10) value within
them, rather than trying to model the target function over the entire data
space. It also provides more control over the support/average-target-value
tradeoﬀ.

Exercise 14.3 addresses an issue that arises with either of these methods
when we generate random data from the product of the marginal distribu-
tions.

14.2.7 Example: Market Basket Analysis (Continued)

We illustrate the use of PRIM on the demographics data of Table 14.1.

Three of the high-support generalized item sets emerging from the PRIM

analysis were the following:

Item set 1: Support= 24%.

}









500

14. Unsupervised Learning

marital status = married

householder status = own

type of home

= apartment 






Item set 2: Support= 24%.

age
marital status
occupation
householder status







Item set 3: Support= 15%.

24
living together-not married, single
professional, homemaker, retired
rent, live with family

}

≤
∈ {
/
∈ {
∈ {

}

householder status = rent



≤

type of home
number in household

= house
2
number of children = 0
occupation
income








Generalized association rules derived from these item sets with conﬁdence
(14.8) greater than 95% are the following:

homemaker, student, unemployed
[$20,000, $150,000]

/
∈ {
∈









}

Association rule 1: Support 25%, conﬁdence 99.7% and lift 1.35.

marital status = married

householder status = own

(cid:20)

(cid:21)

⇓
type of home

= apartment

Association rule 2: Support 25%, conﬁdence 98.7% and lift 1.97.

age
occupation
householder status





≤
/
∈ {
∈ {

24
professional, homemaker, retired
rent, live with family

}

}





marital status

single, living together-not married

}

⇓

∈ {

Association rule 3: Support 25%, conﬁdence 95.9% and lift 2.61.

householder status = own

type of home

= apartment

(cid:21)

(cid:20)

⇓
marital status = married

6
6
6
6
Association rule 4: Support 15%, conﬁdence 95.4% and lift 1.50.

14.3 Cluster Analysis

501









householder status = rent

type of home
number in household
occupation
income

= house
2
homemaker, student, unemployed
[$20,000, $150,000]

≤
/
∈ {
∈

}

⇓
number of children = 0









There are no great surprises among these particular rules. For the most
part they verify intuition. In other contexts where there is less prior in-
formation available, unexpected results have a greater chance to emerge.
These results do illustrate the type of information generalized association
rules can provide, and that the supervised learning approach, coupled with
a ruled induction method such as CART or PRIM, can uncover item sets
exhibiting high associations among their constituents.

How do these generalized association rules compare to those found earlier
by the Apriori algorithm? Since the Apriori procedure gives thousands of
rules, it is diﬃcult to compare them. However some general points can be
made. The Apriori algorithm is exhaustive—it ﬁnds all rules with support
greater than a speciﬁed amount. In contrast, PRIM is a greedy algorithm
and is not guaranteed to give an “optimal” set of rules. On the other hand,
the Apriori algorithm can deal only with dummy variables and hence could
not ﬁnd some of the above rules. For example, since type of home is a
categorical input, with a dummy variable for each level, Apriori could not
ﬁnd a rule involving the set

type of home

= apartment.

To ﬁnd this set, we would have to code a dummy variable for apartment
versus the other categories of type of home. It will not generally be feasible
to precode all such potentially interesting comparisons.

14.3 Cluster Analysis

Cluster analysis, also called data segmentation, has a variety of goals. All
relate to grouping or segmenting a collection of objects into subsets or
“clusters,” such that those within each cluster are more closely related to
one another than objects assigned to diﬀerent clusters. An object can be
described by a set of measurements, or by its relation to other objects.
In addition, the goal is sometimes to arrange the clusters into a natural
hierarchy. This involves successively grouping the clusters themselves so

6
6
502

14. Unsupervised Learning

2
X

•
•

•
•

•
•
•

•

•
•
•
•
•
•
•

•
•

•
•

•

•

•

•

•
•

•
•
•
•

•

•
•

•
•
•
•
•

•

•
•

••
•
•
•
•
•

•
••
•
•
•
•
•
•
•
•
••
• •
•
•
• •
•
•
•
•

•

•

•

•

•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
••
•

•

•
•
•
•
•
•

•
•
•
•
•
••
•
•
•
•
•
• •
• •
•
•
•
•
•
•
•

•

•
•
•
•
•

•
•

•

•
•
•
•
•
•
•
•

•

•
•

•
•
•

•
•

•

•

X1

FIGURE 14.4. Simulated data in the plane, clustered into three classes (repre-
sented by orange, blue and green) by the K-means clustering algorithm

that at each level of the hierarchy, clusters within the same group are more
similar to each other than those in diﬀerent groups.

Cluster analysis is also used to form descriptive statistics to ascertain
whether or not the data consists of a set distinct subgroups, each group
representing objects with substantially diﬀerent properties. This latter goal
requires an assessment of the degree of diﬀerence between the objects as-
signed to the respective clusters.

Central to all of the goals of cluster analysis is the notion of the degree of
similarity (or dissimilarity) between the individual objects being clustered.
A clustering method attempts to group the objects based on the deﬁnition
of similarity supplied to it. This can only come from subject matter consid-
erations. The situation is somewhat similar to the speciﬁcation of a loss or
cost function in prediction problems (supervised learning). There the cost
associated with an inaccurate prediction depends on considerations outside
the data.

Figure 14.4 shows some simulated data clustered into three groups via
the popular K-means algorithm. In this case two of the clusters are not
well separated, so that “segmentation” more accurately describes the part
of this process than “clustering.” K-means clustering starts with guesses
for the three cluster centers. Then it alternates the following steps until
convergence:

•

for each data point, the closest cluster center (in Euclidean distance)
is identiﬁed;

14.3 Cluster Analysis

503

•

each cluster center is replaced by the coordinate-wise average of all
data points that are closest to it.

We describe K-means clustering in more detail later, including the prob-
lem of how to choose the number of clusters (three in this example). K-
means clustering is a top-down procedure, while other cluster approaches
that we discuss are bottom-up. Fundamental to all clustering techniques is
the choice of distance or dissimilarity measure between two objects. We
ﬁrst discuss distance measures before describing a variety of algorithms for
clustering.

14.3.1 Proximity Matrices

Sometimes the data is represented directly in terms of the proximity (alike-
ness or aﬃnity) between pairs of objects. These can be either similarities or
dissimilarities (diﬀerence or lack of aﬃnity). For example, in social science
experiments, participants are asked to judge by how much certain objects
diﬀer from one another. Dissimilarities can then be computed by averaging
over the collection of such judgments. This type of data can be represented
N matrix D, where N is the number of objects, and each element
by an N
dii′ records the proximity between the ith and i′th objects. This matrix is
then provided as input to the clustering algorithm.

×

Most algorithms presume a matrix of dissimilarities with nonnegative
entries and zero diagonal elements: dii = 0, i = 1, 2, . . . , N. If the original
data were collected as similarities, a suitable monotone-decreasing function
can be used to convert them to dissimilarities. Also, most algorithms as-
sume symmetric dissimilarity matrices, so if the original matrix D is not
symmetric it must be replaced by (D+DT )/2. Subjectively judged dissimi-
larities are seldom distances in the strict sense, since the triangle inequality
dii′
does not hold. Thus, some algorithms
that assume distances cannot be used with such data.

dik +di′k, for all k

1, . . . , N

∈ {

≤

}

14.3.2 Dissimilarities Based on Attributes

Most often we have measurements xij for i = 1, 2, . . . , N , on variables
j = 1, 2, . . . , p (also called attributes). Since most of the popular clustering
algorithms take a dissimilarity matrix as their input, we must ﬁrst construct
pairwise dissimilarities between the observations. In the most common case,
we deﬁne a dissimilarity dj(xij, xi′j) between values of the jth attribute,
and then deﬁne

p

D(xi, xi′ ) =

dj(xij, xi′j)

(14.20)

as the dissimilarity between objects i and i′. By far the most common
choice is squared distance

j=1
X

504

14. Unsupervised Learning

dj(xij, xi′j) = (xij −

xi′j)2.

(14.21)

However, other choices are possible, and can lead to potentially diﬀerent
results. For nonquantitative attributes (e.g., categorical data), squared dis-
tance may not be appropriate. In addition, it is sometimes desirable to
weigh attributes diﬀerently rather than giving them equal weight as in
(14.20).

We ﬁrst discuss alternatives in terms of the attribute type:

Quantitative variables. Measurements of this type of variable or attribute
are represented by continuous real-valued numbers. It is natural to
deﬁne the “error” between them as a monotone-increasing function
of their absolute diﬀerence

d(xi, xi′ ) = l(

xi −

|

xi′

).

|

xi′ )2, a common choice is the identity
Besides squared-error loss (xi −
(absolute error). The former places more emphasis on larger diﬀer-
ences than smaller ones. Alternatively, clustering can be based on the
correlation

ρ(xi, xi′ ) =

,

(14.22)

j(xij −
j(xij −
P

¯xi)(xi′j −
¯xi)2

¯xi′ )
j(xi′j −

¯xi′ )2

qP

P

with ¯xi =
j xij/p. Note that this is averaged over variables, not ob-
servations. If the observations are ﬁrst standardized, then
j(xij −
xi′j)2
ρ(xi, xi′ )). Hence clustering based on correlation (simi-
larity) is equivalent to that based on squared distance (dissimilarity).

P
2(1
−

P

∝

Ordinal variables. The values of this type of variable are often represented
as contiguous integers, and the realizable values are considered to be
an ordered set. Examples are academic grades (A, B, C, D, F), degree
of preference (can’t stand, dislike, OK, like, terriﬁc). Rank data are a
special kind of ordinal data. Error measures for ordinal variables are
generally deﬁned by replacing their M original values with

i

1/2

−
M

, i = 1, . . . , M

(14.23)

in the prescribed order of their original values. They are then treated
as quantitative variables on this scale.

Categorical variables. With unordered categorical (also called nominal)
variables, the degree-of-diﬀerence between pairs of values must be
delineated explicitly. If the variable assumes M distinct values, these
can be arranged in a symmetric M
M matrix with elements Lrr′ =
×
0. The most common choice is Lrr′ = 1 for all
Lr′r, Lrr = 0, Lrr′
= r′, while unequal losses can be used to emphasize some errors
r
more than others.

≥

6
14.3 Cluster Analysis

505

14.3.3 Object Dissimilarity

Next we deﬁne a procedure for combining the p-individual attribute dissim-
ilarities dj(xij, xi′j), j = 1, 2, . . . , p into a single overall measure of dissim-
ilarity D(xi, xi′ ) between two objects or observations (xi, xi′ ) possessing
the respective attribute values. This is nearly always done by means of a
weighted average (convex combination)

D(xi, xi′ ) =

p

j=1
X

wj ·

p

dj(xij, xi′j);

wj = 1.

(14.24)

j=1
X

Here wj is a weight assigned to the jth attribute regulating the relative
inﬂuence of that variable in determining the overall dissimilarity between
objects. This choice should be based on subject matter considerations.

It is important to realize that setting the weight wj to the same value
for each variable (say, wj = 1
j) does not necessarily give all attributes
equal inﬂuence. The inﬂuence of the jth attribute Xj on object dissimilarity
D(xi, xi′ ) (14.24) depends upon its relative contribution to the average
object dissimilarity measure over all pairs of observations in the data set

∀

¯D =

1
N 2

N

N

i=1
X

Xi′=1

D(xi, xi′ ) =

p

j=1
X

¯dj,

wj ·

with

¯dj =

1
N 2

N

N

dj(xij, xi′j)

(14.25)

Xi′=1
i=1
X
being the average dissimilarity on the jth attribute. Thus, the relative in-
1/ ¯dj would give all
¯dj, and setting wj ∼
ﬂuence of the jth variable is wj ·
attributes equal inﬂuence in characterizing overall dissimilarity between ob-
jects. For example, with p quantitative variables and squared-error distance
used for each coordinate, then (14.24) becomes the (weighted) squared Eu-
clidean distance

DI (xi, xi′ ) =

p

j=1
X

wj ·

(xij −

xi′j)2

(14.26)

between pairs of points in an IRp, with the quantitative variables as axes.
In this case (14.25) becomes

¯dj =

1
N 2

N

N

(xij −

Xi′=1

i=1
X

xi′j)2 = 2

varj,

·

(14.27)

where varj is the sample estimate of Var(Xj). Thus, the relative impor-
tance of each such variable is proportional to its variance over the data

506

14. Unsupervised Learning

•

•

•
•
•
•
•
•
••
•
•
•
•
•
••
•••
•
•
•
•
•
•
•
•
•
•
••
• •
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•

•

•

•

•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•••
•
•
•
••
•
•
•
•
•
• • •
•
•
•
•
•
••
••
•
•
•
•
•
•

•

2
X

2
X

4

2

0

2
-

4
-

6
-

2

1

0

1
-

2
-

•

•
•

•

•

•

•

•

•

•

•
•
•
•
•
•
•
•
•
•
•••
•
•
•
•
•
•
•
•
•
•
•
•
•
•• •
•
•
•
•
••
•
•
•
•
•

•
•

•
••

•

•

••

•

•
•
•
•
•
•
•

•
•
•
•
•
••
•
••
•
•
•
•
•
•
•
•
• •
•
•
• •
•
•
•
•
•
•

•

•

•

-6

-4

-2

0

2

4

-2

-1

0

1

2

X1

X1

FIGURE 14.5. Simulated data: on the left, K-means clustering (with K=2) has
been applied to the raw data. The two colors indicate the cluster memberships. On
the right, the features were ﬁrst standardized before clustering. This is equivalent
to using feature weights 1/[2
var(Xj)]. The standardization has obscured the two
well-separated groups. Note that each plot uses the same units in the horizontal
and vertical axes.

·

set. In general, setting wj = 1/ ¯dj for all attributes, irrespective of type,
will cause each one of them to equally inﬂuence the overall dissimilarity
between pairs of objects (xi, xi′ ). Although this may seem reasonable, and
is often recommended, it can be highly counterproductive. If the goal is to
segment the data into groups of similar objects, all attributes may not con-
tribute equally to the (problem-dependent) notion of dissimilarity between
objects. Some attribute value diﬀerences may reﬂect greater actual object
dissimilarity in the context of the problem domain.

If the goal is to discover natural groupings in the data, some attributes
may exhibit more of a grouping tendency than others. Variables that are
more relevant in separating the groups should be assigned a higher inﬂu-
ence in deﬁning object dissimilarity. Giving all attributes equal inﬂuence
in this case will tend to obscure the groups to the point where a clustering
algorithm cannot uncover them. Figure 14.5 shows an example.

Although simple generic prescriptions for choosing the individual at-
tribute dissimilarities dj(xij, xi′j) and their weights wj can be comforting,
there is no substitute for careful thought in the context of each individ-
ual problem. Specifying an appropriate dissimilarity measure is far more
important in obtaining success with clustering than choice of clustering
algorithm. This aspect of the problem is emphasized less in the cluster-
ing literature than the algorithms themselves, since it depends on domain
knowledge speciﬁcs and is less amenable to general research.

14.3 Cluster Analysis

507

Finally, often observations have missing values in one or more of the
attributes. The most common method of incorporating missing values in
dissimilarity calculations (14.24) is to omit each observation pair xij, xi′j
having at least one value missing, when computing the dissimilarity be-
tween observations xi and x′
i. This method can fail in the circumstance
when both observations have no measured values in common. In this case
both observations could be deleted from the analysis. Alternatively, the
missing values could be imputed using the mean or median of each attribute
over the nonmissing data. For categorical variables, one could consider the
value “missing” as just another categorical value, if it were reasonable to
consider two objects as being similar if they both have missing values on
the same variables.

14.3.4 Clustering Algorithms

The goal of cluster analysis is to partition the observations into groups
(“clusters”) so that the pairwise dissimilarities between those assigned to
the same cluster tend to be smaller than those in diﬀerent clusters. Clus-
tering algorithms fall into three distinct types: combinatorial algorithms,
mixture modeling, and mode seeking.

Combinatorial algorithms work directly on the observed data with no
direct reference to an underlying probability model. Mixture modeling sup-
poses that the data is an i.i.d sample from some population described by a
probability density function. This density function is characterized by a pa-
rameterized model taken to be a mixture of component density functions;
each component density describes one of the clusters. This model is then ﬁt
to the data by maximum likelihood or corresponding Bayesian approaches.
Mode seekers (“bump hunters”) take a nonparametric perspective, attempt-
ing to directly estimate distinct modes of the probability density function.
Observations “closest” to each respective mode then deﬁne the individual
clusters.

Mixture modeling is described in Section 6.8. The PRIM algorithm, dis-
cussed in Sections 9.3 and 14.2.5, is an example of mode seeking or “bump
hunting.” We discuss combinatorial algorithms next.

14.3.5 Combinatorial Algorithms

The most popular clustering algorithms directly assign each observation
to a group or cluster without regard to a probability model describing the
.
data. Each observation is uniquely labeled by an integer i
}
A prespeciﬁed number of clusters K < N is postulated, and each one is
labeled by an integer k
. Each observation is assigned to one
}
and only one cluster. These assignments can be characterized by a many-
to-one mapping, or encoder k = C(i), that assigns the ith observation to
the kth cluster. One seeks the particular encoder C ∗(i) that achieves the

1, . . . , K

∈ {

∈ {

· · ·

, N

1,

508

14. Unsupervised Learning

required goal (details below), based on the dissimilarities d(xi, xi′ ) between
every pair of observations. These are speciﬁed by the user as described
above. Generally, the encoder C(i) is explicitly delineated by giving its
value (cluster assignment) for each observation i. Thus, the “parameters”
of the procedure are the individual cluster assignments for each of the N
observations. These are adjusted so as to minimize a “loss” function that
characterizes the degree to which the clustering goal is not met.

One approach is to directly specify a mathematical loss function and
attempt to minimize it through some combinatorial optimization algorithm.
Since the goal is to assign close points to the same cluster, a natural loss
(or “energy”) function would be

W (C) =

1
2

K

d(xi, xi′ ).

(14.28)

Xk=1 XC(i)=k XC(i′)=k
This criterion characterizes the extent to which observations assigned to
the same cluster tend to be close to one another. It is sometimes referred
to as the “within cluster” point scatter since

T =

1
2

N

N

i=1
X

Xi′=1

dii′ =

1
2

K

Xk=1 XC(i)=k

or





XC(i′)=k

dii′ +

dii′

XC(i′)6=k

,





T = W (C) + B(C),

where dii′ = d(xi, xi′ ). Here T is the total point scatter, which is a constant
given the data, independent of cluster assignment. The quantity

B(C) =

1
2

K

Xk=1 XC(i)=k XC(i′)6=k

dii′

(14.29)

is the between-cluster point scatter. This will tend to be large when obser-
vations assigned to diﬀerent clusters are far apart. Thus one has

W (C) = T

B(C)

−

and minimizing W (C) is equivalent to maximizing B(C).

Cluster analysis by combinatorial optimization is straightforward in prin-
ciple. One simply minimizes W or equivalently maximizes B over all pos-
sible assignments of the N data points to K clusters. Unfortunately, such
optimization by complete enumeration is feasible only for very small data
sets. The number of distinct assignments is (Jain and Dubes, 1988)

S(N, K) =

1
K!

K

(
Xk=1

1)K−k

−

K
k

(cid:18)

(cid:19)

kN .

(14.30)

For example, S(10, 4) = 34, 105 which is quite feasible. But, S(N, K) grows
very rapidly with increasing values of its arguments. Already S(19, 4)

≃

14.3 Cluster Analysis

509

1010, and most clustering problems involve much larger data sets than
N = 19. For this reason, practical clustering algorithms are able to examine
only a very small fraction of all possible encoders k = C(i). The goal is to
identify a small subset that is likely to contain the optimal one, or at least
a good suboptimal partition.

Such feasible strategies are based on iterative greedy descent. An initial
partition is speciﬁed. At each iterative step, the cluster assignments are
changed in such a way that the value of the criterion is improved from
its previous value. Clustering algorithms of this type diﬀer in their pre-
scriptions for modifying the cluster assignments at each iteration. When
the prescription is unable to provide an improvement, the algorithm ter-
minates with the current assignments as its solution. Since the assignment
of observations to clusters at any iteration is a perturbation of that for the
previous iteration, only a very small fraction of all possible assignments
(14.30) are examined. However, these algorithms converge to local optima
which may be highly suboptimal when compared to the global optimum.

14.3.6 K-means

The K-means algorithm is one of the most popular iterative descent clus-
tering methods. It is intended for situations in which all variables are of
the quantitative type, and squared Euclidean distance

d(xi, xi′ ) =

p

j=1
X

(xij −

xi′j)2 =

xi −

||

xi′

2

||

is chosen as the dissimilarity measure. Note that weighted Euclidean dis-
tance can be used by redeﬁning the xij values (Exercise 14.1).

The within-point scatter (14.28) can be written as

K

W (C) =

1
2

=

K

Xk=1 XC(i)=k XC(i′)=k
Nk
xi −

||

Xk=1

XC(i)=k

xi −

||

xi′

2

||

2,

¯xk||

(14.31)

where ¯xk = (¯x1k, . . . , ¯xpk) is the mean vector associated with the kth clus-
N
ter, and Nk =
i=1 I(C(i) = k). Thus, the criterion is minimized by
assigning the N observations to the K clusters in such a way that within
each cluster the average dissimilarity of the observations from the cluster
mean, as deﬁned by the points in that cluster, is minimized.

P

An iterative descent algorithm for solving

510

14. Unsupervised Learning

Algorithm 14.1 K-means Clustering.

1. For a given cluster assignment C, the total cluster variance (14.33) is
yielding the means of the

minimized with respect to
currently assigned clusters (14.32).

m1, . . . , mK }
{

2. Given a current set of means

, (14.33) is minimized by
assigning each observation to the closest (current) cluster mean. That
is,

m1, . . . , mK }
{

C(i) = argmin

1≤k≤K ||

xi −

mk||

2.

(14.34)

3. Steps 1 and 2 are iterated until the assignments do not change.

C ∗ = min
C

K

Nk

xi −

¯xk||

||

2

Xk=1
can be obtained by noting that for any set of observations S

XC(i)=k

¯xS = argmin

m

xi −

||

m

||

2.

(14.32)

Xi∈S

Hence we can obtain C ∗ by solving the enlarged optimization problem

K

Nk

min
C,{mk}K
1

xi −

mk||

||

2.

(14.33)

XC(i)=k
This can be minimized by an alternating optimization procedure given in
Algorithm 14.1.

Xk=1

Each of steps 1 and 2 reduces the value of the criterion (14.33), so that
convergence is assured. However, the result may represent a suboptimal
local minimum. The algorithm of Hartigan and Wong (1979) goes further,
and ensures that there is no single switch of an observation from one group
to another group that will decrease the objective. In addition, one should
start the algorithm with many diﬀerent random choices for the starting
means, and choose the solution having smallest value of the objective func-
tion.

Figure 14.6 shows some of the K-means iterations for the simulated data
of Figure 14.4. The centroids are depicted by “O”s. The straight lines show
the partitioning of points, each sector being the set of points closest to
each centroid. This partitioning is called the Voronoi tessellation. After 20
iterations the procedure has converged.

14.3.7 Gaussian Mixtures as Soft K-means Clustering

The K-means clustering procedure is closely related to the EM algorithm
for estimating a certain Gaussian mixture model. (Sections 6.8 and 8.5.1).

14.3 Cluster Analysis

511

Initial Centroids

Initial Partition

6

4

2

0

2
-

•
•

•
•

•
•
•
•
•
•
•
•

•
••
•
••
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•• • •
•
•
• •
•
•
• •
•
•
•
•
•

•

•
•

•
•

•
•

•
•
•
•
•
•
•
•

•
••
•
••
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•• • •
•
•
• •
•
•
• •
•
•
•
•
•

•

•
•

•

•
•
•
•
•
•
•
•
•
•
•
•
•

•

•
••
• •
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
• •
•
• •
•
• •
••
•
• •
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
• •
•
•

•
•

•

•
•
•
•
•
•
•
•

•
•
•

•

•
•
•
•
•
•
•
•
•
•
•
•
•

•

•
••
• •
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
• •
•
• •
•
• •
••
•
• •
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
• •
•
•

•
•

•

•
•
•
•
•
•
•
•

•
•
•

-4

-2

0

2

4

6

Iteration Number  2

Iteration Number  20

•
•

•
•

•
•
•
•
•
•
•
•

•
•

•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
• •
•
•
•
•
•
•
•

•

•
•

•

•
•
•
•
•
•
•
•
•
•
•
•
•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
• •
• •
•
• •
••
•
• •
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
• •
•
•

•
•
•
•
•
•
•
•

•
•

•
•

•
•
•
•
•
•
•
•

•
••
•
•
••
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•• • •
•
•
• •
•
•
• •
•
•
•
•
•

•

•
•

•
•
•

•
•
•
•
•
•

•

•

•
•
•
•
•
•
•
•
•
•
•
•
•

•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
• •
• •
•
• •
••
•
• •
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
• •
•
•

•
•
•
•
•
•
•
•

•
•
•

•
•
•
•
•
•

•

FIGURE 14.6. Successive iterations of the K-means clustering algorithm for
the simulated data of Figure 14.4.

512

14. Unsupervised Learning

σ = 1.0

σ = 1.0

s
e
i
t
i
l
i

i

b
s
n
o
p
s
e
R

s
e
i
t
i
l
i

i

b
s
n
o
p
s
e
R

•

σ = 0.2

•

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

0
.
1

8
.
0

6
.
0

4
.
0

2
.

0

0

.

0

•

σ = 0.2

•

−

FIGURE 14.7. (Left panels:) two Gaussian densities g0(x) and g1(x) (blue and
orange) on the real line, and a single data point (green dot) at x = 0.5. The colored
squares are plotted at x =
1.0 and x = 1.0, the means of each density. (Right
panels:) the relative densities g0(x)/(g0(x) + g1(x)) and g1(x)/(g0(x) + g1(x)),
called the “responsibilities” of each cluster, for this data point. In the top panels,
the Gaussian standard deviation σ = 1.0; in the bottom panels σ = 0.2. The
EM algorithm uses these responsibilities to make a “soft” assignment of each
data point to each of the two clusters. When σ is fairly large, the responsibilities
can be near 0.5 (they are 0.36 and 0.64 in the top right panel). As σ
0, the
responsibilities
1, for the cluster center closest to the target point, and 0 for
all other clusters. This “hard” assignment is seen in the bottom right panel.

→

→

The E-step of the EM algorithm assigns “responsibilities” for each data
point based in its relative density under each mixture component, while
the M-step recomputes the component density parameters based on the
current responsibilities. Suppose we specify K mixture components, each
with a Gaussian density having scalar covariance matrix σ2I. Then the
relative density under each mixture component is a monotone function of
the Euclidean distance between the data point and the mixture center.
Hence in this setup EM is a “soft” version of K-means clustering, making
probabilistic (rather than deterministic) assignments of points to cluster
centers. As the variance σ2
0, these probabilities become 0 and 1, and
the two methods coincide. Details are given in Exercise 14.2. Figure 14.7
illustrates this result for two clusters on the real line.

→

14.3.8 Example: Human Tumor Microarray Data

We apply K-means clustering to the human tumor microarray data de-
scribed in Chapter 1. This is an example of high-dimensional clustering.

14.3 Cluster Analysis

513

•

s
e
r
a
u
q
S

f
o
m
u
S

0
0
0
0
4
2

0
0
0
0
0
2

0
0
0
0
6
1

•

•

2

•

4

•

•

6

Number of Clusters K

•

•

8

•

•

10

FIGURE 14.8. Total within-cluster sum of squares for K-means clustering ap-
plied to the human tumor microarray data.

TABLE 14.2. Human tumor data: number of cancer cases of each type, in each
of the three clusters from K-means clustering.

Cluster
1
2
3
Cluster
1
2
3

Breast
3
2
2
Melanoma
1
7
0

CNS
5
0
0
NSCLC
7
2
0

Colon
0
0
7
Ovarian
6
0
0

K562
0
2
0
Prostate
2
0
0

Leukemia
0
6
0
Renal
9
0
0

MCF7
0
2
0
Unknown
1
0
0

×

The data are a 6830
64 matrix of real numbers, each representing an
expression measurement for a gene (row) and sample (column). Here we
cluster the samples, each of which is a vector of length 6830, correspond-
ing to expression values for the 6830 genes. Each sample has a label such
as breast (for breast cancer), melanoma, and so on; we don’t use these la-
bels in the clustering, but will examine posthoc which labels fall into which
clusters.

We applied K-means clustering with K running from 1 to 10, and com-
puted the total within-sum of squares for each clustering, shown in Fig-
ure 14.8. Typically one looks for a kink in the sum of squares curve (or its
logarithm) to locate the optimal number of clusters (see Section 14.3.11).
Here there is no clear indication: for illustration we chose K = 3 giving the
three clusters shown in Table 14.2.

 
 
514

14. Unsupervised Learning

FIGURE 14.9. Sir Ronald A. Fisher (1890
1962) was one of the founders
of modern day statistics, to whom we owe maximum-likelihood, suﬃciency, and
1024 grayscale
many other fundamental concepts. The image on the left is a 1024
image at 8 bits per pixel. The center image is the result of 2
2 block VQ, using
200 code vectors, with a compression rate of 1.9 bits/pixel. The right image uses
only four code vectors, with a compression rate of 0.50 bits/pixel

×

×

−

We see that the procedure is successful at grouping together samples of
the same cancer. In fact, the two breast cancers in the second cluster were
later found to be misdiagnosed and were melanomas that had metastasized.
However, K-means clustering has shortcomings in this application. For one,
it does not give a linear ordering of objects within a cluster: we have simply
listed them in alphabetic order above. Secondly, as the number of clusters
K is changed, the cluster memberships can change in arbitrary ways. That
is, with say four clusters, the clusters need not be nested within the three
clusters above. For these reasons, hierarchical clustering (described later),
is probably preferable for this application.

14.3.9 Vector Quantization

The K-means clustering algorithm represents a key tool in the apparently
unrelated area of image and signal compression, particularly in vector quan-
tization or VQ (Gersho and Gray, 1992). The left image in Figure 14.92 is a
digitized photograph of a famous statistician, Sir Ronald Fisher. It consists
1024 pixels, where each pixel is a grayscale value ranging from 0
of 1024
to 255, and hence requires 8 bits of storage per pixel. The entire image oc-
cupies 1 megabyte of storage. The center image is a VQ-compressed version
of the left panel, and requires 0.239 of the storage (at some loss in quality).
The right image is compressed even more, and requires only 0.0625 of the
storage (at a considerable loss in quality).

×

The version of VQ implemented here ﬁrst breaks the image into small
512 blocks of four
2 blocks of pixels. Each of the 512

blocks, in this case 2

×

×

2This example was prepared by Maya Gupta.

14.3 Cluster Analysis

515

numbers is regarded as a vector in IR4. A K-means clustering algorithm
(also known as Lloyd’s algorithm in this context) is run in this space.
The center image uses K = 200, while the right image K = 4. Each of
the 512
512 pixel blocks (or points) is approximated by its closest cluster
centroid, known as a codeword. The clustering process is called the encoding
step, and the collection of centroids is called the codebook.

×

×

To represent the approximated image, we need to supply for each block
the identity of the codebook entry that approximates it. This will require
log2(K) bits per block. We also need to supply the codebook itself, which
4 real numbers (typically negligible). Overall, the storage for the
is K
compressed image amounts to log2(K)/(4
8) of the original (0.239 for
K = 200, 0.063 for K = 4). This is typically expressed as a rate in bits
per pixel: log2(K)/4, which are 1.91 and 0.50, respectively. The process
of constructing the approximate image from the centroids is called the
decoding step.

·

Why do we expect VQ to work at all? The reason is that for typical
everyday images like photographs, many of the blocks look the same. In
this case there are many almost pure white blocks, and similarly pure gray
blocks of various shades. These require only one block each to represent
them, and then multiple pointers to that block.

What we have described is known as lossy compression, since our im-
ages are degraded versions of the original. The degradation or distortion is
usually measured in terms of mean squared error. In this case D = 0.89
for K = 200 and D = 16.95 for K = 4. More generally a rate/distortion
curve would be used to assess the tradeoﬀ. One can also perform lossless
compression using block clustering, and still capitalize on the repeated pat-
terns. If you took the original image and losslessly compressed it, the best
you would do is 4.48 bits per pixel.

We claimed above that log2(K) bits were needed to identify each of the K
codewords in the codebook. This uses a ﬁxed-length code, and is ineﬃcient
if some codewords occur many more times than others in the image. Using
Shannon coding theory, we know that in general a variable length code
K
will do better, and the rate then becomes
ℓ=1 pℓ log2(pℓ)/4. The term
in the numerator is the entropy of the distribution pℓ of the codewords
in the image. Using variable length coding our rates come down to 1.42
and 0.39, respectively. Finally, there are many generalizations of VQ that
have been developed: for example, tree-structured VQ ﬁnds the centroids
with a top-down, 2-means style algorithm, as alluded to in Section 14.3.12.
This allows successive reﬁnement of the compression. Further details may
be found in Gersho and Gray (1992).

P

−

14.3.10 K-medoids

As discussed above, the K-means algorithm is appropriate when the dis-
similarity measure is taken to be squared Euclidean distance D(xi, xi′ )

516

14. Unsupervised Learning

Algorithm 14.2 K-medoids Clustering.

1. For a given cluster assignment C ﬁnd the observation in the cluster

minimizing total distance to other points in that cluster:

i∗
k = argmin
{i:C(i)=k}

XC(i′)=k

D(xi, xi′ ).

(14.35)

Then mk = xi∗
cluster centers.

k , k = 1, 2, . . . , K are the current estimates of the

2. Given a current set of cluster centers

, minimize the to-
tal error by assigning each observation to the closest (current) cluster
center:

m1, . . . , mK }
{

C(i) = argmin
1≤k≤K

D(xi, mk).

(14.36)

3. Iterate steps 1 and 2 until the assignments do not change.

(14.112). This requires all of the variables to be of the quantitative type. In
addition, using squared Euclidean distance places the highest inﬂuence on
the largest distances. This causes the procedure to lack robustness against
outliers that produce very large distances. These restrictions can be re-
moved at the expense of computation.

The only part of the K-means algorithm that assumes squared Eu-
clidean distance is the minimization step (14.32); the cluster representatives
in (14.33) are taken to be the means of the currently assigned
m1, . . . , mK }
{
clusters. The algorithm can be generalized for use with arbitrarily deﬁned
dissimilarities D(xi, xi′ ) by replacing this step by an explicit optimization
with respect to
in (14.33). In the most common form, cen-
ters for each cluster are restricted to be one of the observations assigned
to the cluster, as summarized in Algorithm 14.2. This algorithm assumes
attribute data, but the approach can also be applied to data described
only by proximity matrices (Section 14.3.1). There is no need to explicitly
compute cluster centers; rather we just keep track of the indices i∗
k.

m1, . . . , mK }
{

Solving (14.32) for each provisional cluster k requires an amount of com-
putation proportional to the number of observations assigned to it, whereas
for solving (14.35) the computation increases to O(N 2
k ). Given a set of clus-
ter “centers,”

, obtaining the new assignments

i1, . . . , iK }
{

C(i) = argmin
1≤k≤K

dii∗

k

(14.37)

requires computation proportional to K
far more computationally intensive than K-means.

·

N as before. Thus, K-medoids is

Alternating between (14.35) and (14.37) represents a particular heuristic

search strategy for trying to solve

14.3 Cluster Analysis

517

TABLE 14.3. Data from a political science survey: values are average pairwise
dissimilarities of countries from a questionnaire given to political science students.

BEL BRA CHI CUB EGY FRA IND ISR USA USS YUG

BRA 5.58
7.00 6.50
CHI
CUB 7.08 7.00 3.83
EGY 4.83 5.08 8.17 5.83
FRA 2.17 5.75 6.67 6.92
IND 6.42 5.00 5.58 6.00
ISR 3.42 5.50 6.42 6.42
USA 2.50 4.92 6.25 7.33
6.08 6.67 4.25 2.67
USS
YUG 5.25 6.83 4.50 3.75
ZAI
4.75 3.00 6.08 6.67

4.92
4.67
5.00
4.50
6.00
5.75
5.00

K

6.42
3.92 6.17
2.25 6.33 2.75
6.17 6.17 6.92 6.17
5.42 6.08 5.83 6.67 3.67
5.58 4.83 6.17 5.67 6.50 6.92

min
C, {ik}K
1

diik .

Xk=1 XC(i)=k

(14.38)

Kaufman and Rousseeuw (1990) propose an alternative strategy for directly
solving (14.38) that provisionally exchanges each center ik with an obser-
vation that is not currently a center, selecting the exchange that produces
the greatest reduction in the value of the criterion (14.38). This is repeated
until no advantageous exchanges can be found. Massart et al. (1983) derive
a branch-and-bound combinatorial method that ﬁnds the global minimum
of (14.38) that is practical only for very small data sets.

Example: Country Dissimilarities

This example, taken from Kaufman and Rousseeuw (1990), comes from a
study in which political science students were asked to provide pairwise dis-
similarity measures for 12 countries: Belgium, Brazil, Chile, Cuba, Egypt,
France, India, Israel, United States, Union of Soviet Socialist Republics,
Yugoslavia and Zaire. The average dissimilarity scores are given in Ta-
ble 14.3. We applied 3-medoid clustering to these dissimilarities. Note that
K-means clustering could not be applied because we have only distances
rather than raw observations. The left panel of Figure 14.10 shows the
dissimilarities reordered and blocked according to the 3-medoid clustering.
The right panel is a two-dimensional multidimensional scaling plot, with
the 3-medoid clusters assignments indicated by colors (multidimensional
scaling is discussed in Section 14.8.) Both plots show three well-separated
clusters, but the MDS display indicates that “Egypt” falls about halfway
between two clusters.

518

14. Unsupervised Learning

I

H
C

B
U
C

S
S
U

G
U
Y

A
R
B

D
N

I

I

A
Z

L
E
B

Y
G
E

A
R
F

R
S

I

USA

ISR

FRA

EGY

BEL

ZAI

IND

BRA

YUG

USS

CUB

i

t

e
a
n
d
r
o
o
C
S
D
M
d
n
o
c
e
S

3

2

1

0

1
-

2
-

ZAI

BRA

IND

EGY

CHI

CUB

USS

YUG

USA

ISR

BEL

FRA

-2

0

2

4

Reordered Dissimilarity Matrix

First MDS Coordinate

FIGURE 14.10. Survey of country dissimilarities. (Left panel:) dissimilarities
reordered and blocked according to 3-medoid clustering. Heat map is coded from
most similar (dark red) to least similar (bright red). (Right panel:) two-dimen-
sional multidimensional scaling plot, with 3-medoid clusters indicated by diﬀerent
colors.

14.3.11 Practical Issues

m1, . . . , mK }
{

In order to apply K-means or K-medoids one must select the number of
clusters K ∗ and an initialization. The latter can be deﬁned by specifying
an initial set of centers
or an initial encoder
C(i). Usually specifying the centers is more convenient. Suggestions range
from simple random selection to a deliberate strategy based on forward
stepwise assignment. At each step a new center ik is chosen to minimize
the criterion (14.33) or (14.38), given the centers i1, . . . , ik−1 chosen at the
previous steps. This continues for K steps, thereby producing K initial
centers with which to begin the optimization algorithm.

i1, . . . , iK }
{

or

A choice for the number of clusters K depends on the goal. For data
segmentation K is usually deﬁned as part of the problem. For example,
a company may employ K sales people, and the goal is to partition a
customer database into K segments, one for each sales person, such that the
customers assigned to each one are as similar as possible. Often, however,
cluster analysis is used to provide a descriptive statistic for ascertaining the
extent to which the observations comprising the data base fall into natural
distinct groupings. Here the number of such groups K ∗ is unknown and
one requires that it, as well as the groupings themselves, be estimated from
the data.

Data-based methods for estimating K ∗ typically examine the within-
cluster dissimilarity WK as a function of the number of clusters K. Separate
. The corresponding values
solutions are obtained for K

1, 2, . . . , Kmax}

∈ {

 
 
14.3 Cluster Analysis

519

generally decrease with increasing K. This will be
W1, W2, . . . , WKmax }
{
the case even when the criterion is evaluated on an independent test set,
since a large number of cluster centers will tend to ﬁll the feature space
densely and thus will be close to all data points. Thus cross-validation
techniques, so useful for model selection in supervised learning, cannot be
utilized in this context.

The intuition underlying the approach is that if there are actually K ∗
distinct groupings of the observations (as deﬁned by the dissimilarity mea-
sure), then for K < K ∗ the clusters returned by the algorithm will each
contain a subset of the true underlying groups. That is, the solution will
not assign observations in the same naturally occurring group to diﬀerent
estimated clusters. To the extent that this is the case, the solution criterion
value will tend to decrease substantially with each successive increase in the
WK , as the natural groups are suc-
number of speciﬁed clusters, WK+1 ≪
cessively assigned to separate clusters. For K > K ∗, one of the estimated
clusters must partition at least one of the natural groups into two sub-
groups. This will tend to provide a smaller decrease in the criterion as K is
further increased. Splitting a natural group, within which the observations
are all quite close to each other, reduces the criterion less than partitioning
the union of two well-separated groups into their proper constituents.

WK −
{

To the extent this scenario is realized, there will be a sharp decrease in
WK+1, at K = K ∗. That
successive diﬀerences in criterion value, WK −
K < K ∗
. An estimate
WK −
is,
}
ˆK ∗ for K ∗ is then obtained by identifying a “kink” in the plot of WK as a
function of K. As with other aspects of clustering procedures, this approach
is somewhat heuristic.

WK+1 |

WK+1 |

} ≫ {

K ∗

K

≥

The recently proposed Gap statistic (Tibshirani et al., 2001b) compares
the curve log WK to the curve obtained from data uniformly distributed
over a rectangle containing the data. It estimates the optimal number of
clusters to be the place where the gap between the two curves is largest.
Essentially this is an automatic way of locating the aforementioned “kink.”
It also works reasonably well when the data fall into a single cluster, and
in that case will tend to estimate the optimal number of clusters to be one.
This is the scenario where most other competing methods fail.

Figure 14.11 shows the result of the Gap statistic applied to simulated
data of Figure 14.4. The left panel shows log WK for k = 1, 2, . . . , 8 clusters
(green curve) and the expected value of log WK over 20 simulations from
uniform data (blue curve). The right panel shows the gap curve, which is the
expected curve minus the observed curve. Shown also are error bars of half-
width s′
1 + 1/20, where sK is the standard deviation of log WK
over the 20 simulations. The Gap curve is maximized at K = 2 clusters. If
G(K) is the Gap curve at K clusters, the formal rule for estimating K ∗ is

K = sK

p

K ∗ = argmin
K {

K

|

G(K)

≥

G(K + 1)

s′
.
K+1}

−

(14.39)

520

14. Unsupervised Learning

0 •
•

.
0

1

W
g
o
l

−
K
W
g
o
l

5
.
0
-

0
.
1
-

5
.
1
-

0
.
2
-

5
.
2
-

0
.
3
-

•

•

•
•

•
•

•
•

2

4

•
•

6

•
•

•
•

8

Number of Clusters

0
.
1

5
.
0

p
a
G

0
.
0

•

5
.
0
-

•

•

•

•

•

•

2

4

6

Number of Clusters

•

8

FIGURE 14.11. (Left panel): observed (green) and expected (blue) values of
log WK for the simulated data of Figure 14.4. Both curves have been translated
to equal zero at one cluster. (Right panel): Gap curve, equal to the diﬀerence
between the observed and expected values of log WK . The Gap estimate K ∗ is the
smallest K producing a gap within one standard deviation of the gap at K + 1;
here K ∗ = 2.

This gives K ∗ = 2, which looks reasonable from Figure 14.4.

14.3.12 Hierarchical Clustering

The results of applying K-means or K-medoids clustering algorithms de-
pend on the choice for the number of clusters to be searched and a starting
conﬁguration assignment. In contrast, hierarchical clustering methods do
not require such speciﬁcations. Instead, they require the user to specify a
measure of dissimilarity between (disjoint) groups of observations, based
on the pairwise dissimilarities among the observations in the two groups.
As the name suggests, they produce hierarchical representations in which
the clusters at each level of the hierarchy are created by merging clusters
at the next lower level. At the lowest level, each cluster contains a single
observation. At the highest level there is only one cluster containing all of
the data.

Strategies for hierarchical clustering divide into two basic paradigms: ag-
glomerative (bottom-up) and divisive (top-down). Agglomerative strategies
start at the bottom and at each level recursively merge a selected pair of
clusters into a single cluster. This produces a grouping at the next higher
level with one less cluster. The pair chosen for merging consist of the two
groups with the smallest intergroup dissimilarity. Divisive methods start
at the top and at each level recursively split one of the existing clusters at

14.3 Cluster Analysis

521

−

that level into two new clusters. The split is chosen to produce two new
groups with the largest between-group dissimilarity. With both paradigms
there are N

1 levels in the hierarchy.

Each level of the hierarchy represents a particular grouping of the data
into disjoint clusters of observations. The entire hierarchy represents an
ordered sequence of such groupings. It is up to the user to decide which
level (if any) actually represents a “natural” clustering in the sense that
observations within each of its groups are suﬃciently more similar to each
other than to observations assigned to diﬀerent groups at that level. The
Gap statistic described earlier can be used for this purpose.

Recursive binary splitting/agglomeration can be represented by a rooted
binary tree. The nodes of the trees represent groups. The root node repre-
sents the entire data set. The N terminal nodes each represent one of the
individual observations (singleton clusters). Each nonterminal node (“par-
ent”) has two daughter nodes. For divisive clustering the two daughters
represent the two groups resulting from the split of the parent; for agglom-
erative clustering the daughters represent the two groups that were merged
to form the parent.

All agglomerative and some divisive methods (when viewed bottom-up)
possess a monotonicity property. That is, the dissimilarity between merged
clusters is monotone increasing with the level of the merger. Thus the
binary tree can be plotted so that the height of each node is proportional
to the value of the intergroup dissimilarity between its two daughters. The
terminal nodes representing individual observations are all plotted at zero
height. This type of graphical display is called a dendrogram.

A dendrogram provides a highly interpretable complete description of
the hierarchical clustering in a graphical format. This is one of the main
reasons for the popularity of hierarchical clustering methods.

For the microarray data, Figure 14.12 shows the dendrogram resulting
from agglomerative clustering with average linkage; agglomerative cluster-
ing and this example are discussed in more detail later in this chapter.
Cutting the dendrogram horizontally at a particular height partitions the
data into disjoint clusters represented by the vertical lines that intersect
it. These are the clusters that would be produced by terminating the pro-
cedure when the optimal intergroup dissimilarity exceeds that threshold
cut value. Groups that merge at high values, relative to the merger values
of the subgroups contained within them lower in the tree, are candidates
for natural clusters. Note that this may occur at several diﬀerent levels,
indicating a clustering hierarchy: that is, clusters nested within clusters.

Such a dendrogram is often viewed as a graphical summary of the data
itself, rather than a description of the results of the algorithm. However,
such interpretations should be treated with caution. First, diﬀerent hierar-
chical methods (see below), as well as small changes in the data, can lead
to quite diﬀerent dendrograms. Also, such a summary will be valid only to
the extent that the pairwise observation dissimilarities possess the hierar-

522

14. Unsupervised Learning

L
A
N
E
R

C
L
C
S
N

T
S
A
E
R
B

I

N
A
R
A
V
O

I

N
A
R
A
V
O

I

A
M
E
K
U
E
L

I

A
M
E
K
U
E
L

I

A
M
E
K
U
E
L

I

A
M
E
K
U
E
L

I

A
M
E
K
U
E
L

A
M
O
N
A
L
E
M

A
M
O
N
A
L
E
M

A
M
O
N
A
L
E
M

A
M
O
N
A
L
E
M

A
M
O
N
A
L
E
M

A
M
O
N
A
L
E
M

A
M
O
N
A
L
E
M

C
L
C
S
N

L
A
N
E
R

C
L
C
S
N

A
M
O
N
A
L
E
M

L
A
N
E
R

L
A
N
E
R

L
A
N
E
R

L
A
N
E
R

L
A
N
E
R

L
A
N
E
R

I

A
M
E
K
U
E
L

o
r
p
e
r
-

B
2
6
5
K

o
r
p
e
r
-

A
2
6
5
K

T
S
A
E
R
B

T
S
A
E
R
B

I

N
A
R
A
V
O

N
W
O
N
K
N
U

I

N
A
R
A
V
O

I

N
A
R
A
V
O

C
L
C
S
N

T
S
A
E
R
B

C
L
C
S
N

C
L
C
S
N

S
N
SC
N
C

T
S
A
E
R
B

T
S
A
E
R
B

N
O
L
O
C

N
O
L
O
C

N
O
L
O
C

N
O
L
O
C

N
O
L
O
C

N
O
L
O
C

N
O
L
O
C

L
A
N
E
R

S
N
C

C
L
C
S
N

E
T
A
T
S
O
R
P

I

N
A
R
A
V
O

E
T
A
T
S
O
R
P

C
L
C
S
N

C
L
C
S
N

S
N
C

S
N
C

o
r
p
e
r
-

A
7
F
C
M

T
S
A
E
R
B

o
r
p
e
r
-

D
7
F
C
M

FIGURE 14.12. Dendrogram from agglomerative hierarchical clustering with
average linkage to the human tumor microarray data.

chical structure produced by the algorithm. Hierarchical methods impose
hierarchical structure whether or not such structure actually exists in the
data.

The extent to which the hierarchical structure produced by a dendro-
gram actually represents the data itself can be judged by the cophenetic
correlation coeﬃcient. This is the correlation between the N (N
1)/2 pair-
wise observation dissimilarities dii′ input to the algorithm and their corre-
sponding cophenetic dissimilarities Cii′ derived from the dendrogram. The
cophenetic dissimilarity Cii′ between two observations (i, i′) is the inter-
group dissimilarity at which observations i and i′ are ﬁrst joined together
in the same cluster.

−

The cophenetic dissimilarity is a very restrictive dissimilarity measure.
1
1)/2 values can be distinct. Also these dissimilarities

First, the Cii′ over the observations must contain many ties, since only N
of the total N (N
obey the ultrametric inequality

−

−

Cii′

max

Cik, Ci′k}
{

≤

(14.40)

14.3 Cluster Analysis

523

for any three observations (i, i′, k). As a geometric example, suppose the
data were represented as points in a Euclidean coordinate system. In order
for the set of interpoint distances over the data to conform to (14.40), the
triangles formed by all triples of points must be isosceles triangles with the
unequal length no longer than the length of the two equal sides (Jain and
Dubes, 1988). Therefore it is unrealistic to expect general dissimilarities
over arbitrary data sets to closely resemble their corresponding cophenetic
dissimilarities as calculated from a dendrogram, especially if there are not
many tied values. Thus the dendrogram should be viewed mainly as a de-
scription of the clustering structure of the data as imposed by the particular
algorithm employed.

Agglomerative Clustering

Agglomerative clustering algorithms begin with every observation repre-
senting a singleton cluster. At each of the N
1 steps the closest two (least
dissimilar) clusters are merged into a single cluster, producing one less clus-
ter at the next higher level. Therefore, a measure of dissimilarity between
two clusters (groups of observations) must be deﬁned.

−

Let G and H represent two such groups. The dissimilarity d(G, H) be-
tween G and H is computed from the set of pairwise observation dissim-
ilarities dii′ where one member of the pair i is in G and the other i′ is
in H. Single linkage (SL) agglomerative clustering takes the intergroup
dissimilarity to be that of the closest (least dissimilar) pair

dSL(G, H) = min
i∈G
i′∈H

dii′ .

(14.41)

This is also often called the nearest-neighbor technique. Complete linkage
(CL) agglomerative clustering (furthest-neighbor technique) takes the in-
tergroup dissimilarity to be that of the furthest (most dissimilar) pair

dCL(G, H) = max
i∈G
i′∈H

dii′ .

(14.42)

Group average (GA) clustering uses the average dissimilarity between the
groups

dGA(G, H) =

dii′

(14.43)

1
NGNH

Xi∈G Xi′∈H

where NG and NH are the respective number of observations in each group.
Although there have been many other proposals for deﬁning intergroup
dissimilarity in the context of agglomerative clustering, the above three are
the ones most commonly used. Figure 14.13 shows examples of all three.

If the data dissimilarities

exhibit a strong clustering tendency, with
each of the clusters being compact and well separated from others, then all
three methods produce similar results. Clusters are compact if all of the

dii′
{

}

524

14. Unsupervised Learning

Average Linkage

Complete Linkage

Single Linkage

FIGURE 14.13. Dendrograms from agglomerative hierarchical clustering of hu-
man tumor microarray data.

observations within them are relatively close together (small dissimilarities)
as compared with observations in diﬀerent clusters. To the extent this is
not the case, results will diﬀer.

∈

∈

Single linkage (14.41) only requires that a single dissimilarity dii′ , i

G
and i′
H, be small for two groups G and H to be considered close
together, irrespective of the other observation dissimilarities between the
groups. It will therefore have a tendency to combine, at relatively low
thresholds, observations linked by a series of close intermediate observa-
tions. This phenomenon, referred to as chaining, is often considered a de-
fect of the method. The clusters produced by single linkage can violate the
“compactness” property that all observations within each cluster tend to
be similar to one another, based on the supplied observation dissimilari-
ties
. If we deﬁne the diameter DG of a group of observations as the
}
largest dissimilarity among its members

dii′
{

DG = max
i∈G
i′∈G

dii′ ,

(14.44)

then single linkage can produce clusters with very large diameters.

Complete linkage (14.42) represents the opposite extreme. Two groups
G and H are considered close only if all of the observations in their union
are relatively similar. It will tend to produce compact clusters with small
diameters (14.44). However, it can produce clusters that violate the “close-
ness” property. That is, observations assigned to a cluster can be much

14.3 Cluster Analysis

525

closer to members of other clusters than they are to some members of their
own cluster.

Group average clustering (14.43) represents a compromise between the
two extremes of single and complete linkage. It attempts to produce rel-
atively compact clusters that are relatively far apart. However, its results
depend on the numerical scale on which the observation dissimilarities dii′
are measured. Applying a monotone strictly increasing transformation h(
)
·
to the dii′ , hii′ = h(dii′ ), can change the result produced by (14.43). In
contrast, (14.41) and (14.42) depend only on the ordering of the dii′ and
are thus invariant to such monotone transformations. This invariance is
often used as an argument in favor of single or complete linkage over group
average methods.

One can argue that group average clustering has a statistical consis-
tency property violated by single and complete linkage. Assume we have
attribute-value data X T = (X1, . . . , Xp) and that each cluster k is a ran-
dom sample from some population joint density pk(x). The complete data
set is a random sample from a mixture of K such densities. The group
average dissimilarity dGA(G, H) (14.43) is an estimate of

d(x, x′) pG(x) pH (x′) dx dx′,

(14.45)

Z Z

where d(x, x′) is the dissimilarity between points x and x′ in the space
of attribute values. As the sample size N approaches inﬁnity dGA(G, H)
(14.43) approaches (14.45), which is a characteristic of the relationship
between the two densities pG(x) and pH (x) . For single linkage, dSL(G, H)
(14.41) approaches zero as N
independent of pG(x) and pH (x) . For
, again
complete linkage, dCL(G, H) (14.42) becomes inﬁnite as N
independent of the two densities. Thus, it is not clear what aspects of the
population distribution are being estimated by dSL(G, H) and dCL(G, H).

→ ∞

→ ∞

Example: Human Cancer Microarray Data (Continued)

The left panel of Figure 14.13 shows the dendrogram resulting from average
linkage agglomerative clustering of the samples (columns) of the microarray
data. The middle and right panels show the result using complete and single
linkage. Average and complete linkage gave similar results, while single
linkage produced unbalanced groups with long thin clusters. We focus on
the average linkage clustering.

Like K-means clustering, hierarchical clustering is successful at clustering
simple cancers together. However it has other nice features. By cutting oﬀ
the dendrogram at various heights, diﬀerent numbers of clusters emerge,
and the sets of clusters are nested within one another. Secondly, it gives
some partial ordering information about the samples. In Figure 14.14, we
have arranged the genes (rows) and samples (columns) of the expression
matrix in orderings derived from hierarchical clustering.

526

14. Unsupervised Learning

Note that if we ﬂip the orientation of the branches of a dendrogram at any
merge, the resulting dendrogram is still consistent with the series of hierar-
chical clustering operations. Hence to determine an ordering of the leaves,
we must add a constraint. To produce the row ordering of Figure 14.14,
we have used the default rule in S-PLUS: at each merge, the subtree with
the tighter cluster is placed to the left (toward the bottom in the rotated
dendrogram in the ﬁgure.) Individual genes are the tightest clusters possi-
ble, and merges involving two individual genes place them in order by their
observation number. The same rule was used for the columns. Many other
rules are possible—for example, ordering by a multidimensional scaling of
the genes; see Section 14.8.

The two-way rearrangement of Figure 14.14 produces an informative pic-
ture of the genes and samples. This picture is more informative than the
randomly ordered rows and columns of Figure 1.3 of Chapter 1. Further-
more, the dendrograms themselves are useful, as biologists can, for example,
interpret the gene clusters in terms of biological processes.

Divisive Clustering

Divisive clustering algorithms begin with the entire data set as a single
cluster, and recursively divide one of the existing clusters into two daugh-
ter clusters at each iteration in a top-down fashion. This approach has not
been studied nearly as extensively as agglomerative methods in the cluster-
ing literature. It has been explored somewhat in the engineering literature
(Gersho and Gray, 1992) in the context of compression. In the clustering
setting, a potential advantage of divisive over agglomerative methods can
occur when interest is focused on partitioning the data into a relatively
small number of clusters.

The divisive paradigm can be employed by recursively applying any of
the combinatorial methods such as K-means (Section 14.3.6) or K-medoids
(Section 14.3.10), with K = 2, to perform the splits at each iteration. How-
ever, such an approach would depend on the starting conﬁguration speciﬁed
at each step. In addition, it would not necessarily produce a splitting se-
quence that possesses the monotonicity property required for dendrogram
representation.

A divisive algorithm that avoids these problems was proposed by Mac-
naughton Smith et al. (1965). It begins by placing all observations in a
single cluster G. It then chooses that observation whose average dissimi-
larity from all the other observations is largest. This observation forms the
ﬁrst member of a second cluster H. At each successive step that observation
in G whose average distance from those in H, minus that for the remaining
observations in G is largest, is transferred to H. This continues until the
corresponding diﬀerence in averages becomes negative. That is, there are
no longer any observations in G that are, on average, closer to those in
H. The result is a split of the original cluster into two daughter clusters,

14.3 Cluster Analysis

527

FIGURE 14.14. DNA microarray data: average linkage hierarchical clustering
has been applied independently to the rows (genes) and columns (samples), de-
termining the ordering of the rows and columns (see text). The colors range from
bright green (negative, under-expressed) to bright red (positive, over-expressed).

528

14. Unsupervised Learning

the observations transferred to H, and those remaining in G. These two
clusters represent the second level of the hierarchy. Each successive level
is produced by applying this splitting procedure to one of the clusters at
the previous level. Kaufman and Rousseeuw (1990) suggest choosing the
cluster at each level with the largest diameter (14.44) for splitting. An al-
ternative would be to choose the one with the largest average dissimilarity
among its members

¯dG =

1
NG

dii′ .

Xi∈G Xi′∈G

The recursive splitting continues until all clusters either become singletons
or all members of each one have zero dissimilarity from one another.

14.4 Self-Organizing Maps

This method can be viewed as a constrained version of K-means clustering,
in which the prototypes are encouraged to lie in a one- or two-dimensional
manifold in the feature space. The resulting manifold is also referred to
as a constrained topological map, since the original high-dimensional obser-
vations can be mapped down onto the two-dimensional coordinate system.
The original SOM algorithm was online—observations are processed one at
a time—and later a batch version was proposed. The technique also bears
a close relationship to principal curves and surfaces, which are discussed in
the next section.

1, 2, . . . , q1}
{

We consider a SOM with a two-dimensional rectangular grid of K proto-
IRp (other choices, such as hexagonal grids, can also be used).
types mj ∈
Each of the K prototypes are parametrized with respect to an integer
coordinate pair ℓj ∈ Q1 × Q2. Here
Q2, and
Q1 =
q2. The mj are initialized, for example, to lie in the two-dimensional
K = q1·
principal component plane of the data (next section). We can think of the
prototypes as “buttons,” “sewn” on the principal component plane in a
regular pattern. The SOM procedure tries to bend the plane so that the
buttons approximate the data points as well as possible. Once the model is
ﬁt, the observations can be mapped down onto the two-dimensional grid.
The observations xi are processed one at a time. We ﬁnd the closest
prototype mj to xi in Euclidean distance in IRp, and then for all neighbors
mk of mj, move mk toward xi via the update

, similarly

mk ←

mk + α(xi −
The “neighbors” of mj are deﬁned to be all mk such that the distance
between ℓj and ℓk is small. The simplest approach uses Euclidean distance,
and “small” is determined by a threshold r. This neighborhood always
includes the closest prototype mj itself.

(14.46)

mk).

14.4 Self-Organizing Maps

529

Notice that distance is deﬁned in the space

Q1 ×Q2 of integer topological
coordinates of the prototypes, rather than in the feature space IRp. The
eﬀect of the update (14.46) is to move the prototypes closer to the data,
but also to maintain a smooth two-dimensional spatial relationship between
the prototypes.

The performance of the SOM algorithm depends on the learning rate
α and the distance threshold r. Typically α is decreased from say 1.0 to
0.0 over a few thousand iterations (one per observation). Similarly r is
decreased linearly from starting value R to 1 over a few thousand iterations.
We illustrate a method for choosing R in the example below.

We have described the simplest version of the SOM. More sophisticated

versions modify the update step according to distance:

mk + αh(

mk ←

ℓj −
k
where the neighborhood function h gives more weight to prototypes mk with
indices ℓk closer to ℓj than to those further away.

)(xi −

(14.47)

ℓkk

mk),

If we take the distance r small enough so that each neighborhood contains
only one point, then the spatial connection between prototypes is lost. In
that case one can show that the SOM algorithm is an online version of
K-means clustering, and eventually stabilizes at one of the local minima
found by K-means. Since the SOM is a constrained version of K-means
clustering, it is important to check whether the constraint is reasonable
in any given problem. One can do this by computing the reconstruction
2, summed over observations, for both methods. This will
error
necessarily be smaller for K-means, but should not be much smaller if the
SOM is a reasonable approximation.

mjk

x
k

−

As an illustrative example, we generated 90 data points in three dimen-
sions, near the surface of a half sphere of radius 1. The points were in each
of three clusters—red, green, and blue—located near (0, 1, 0), (0, 0, 1) and
(1, 0, 0). The data are shown in Figure 14.15

By design, the red cluster was much tighter than the green or blue ones.
(Full details of the data generation are given in Exercise 14.5.) A 5
5 grid
of prototypes was used, with initial grid size R = 2; this meant that about
a third of the prototypes were initially in each neighborhood. We did a
total of 40 passes through the dataset of 90 observations, and let r and α
decrease linearly over the 3600 iterations.

×

In Figure 14.16 the prototypes are indicated by circles, and the points
that project to each prototype are plotted randomly within the correspond-
ing circle. The left panel shows the initial conﬁguration, while the right
panel shows the ﬁnal one. The algorithm has succeeded in separating the
clusters; however, the separation of the red cluster indicates that the man-
ifold has folded back on itself (see Figure 14.17). Since the distances in the
two-dimensional display are not used, there is little indication in the SOM
projection that the red cluster is tighter than the others.

530

14. Unsupervised Learning

1.5

1

0.5

0

−0.5

−1
1.5

1

0.5

0

−0.5

0

−0.5

−1

−1

1.5

1

0.5

FIGURE 14.15. Simulated data in three classes, near the surface of a half–
sphere.

5

4

3

2

1

•

•

•

•

•
••
•
•
• •
•
•
•

•
•
•
•
•
•

•
•
• •
••
•
••
•
•
•

•
•
••
•
••
•
• •
••

1

2

•

•
•

•
•
•
•
•
•
•

•
•
•
•
•
•
•

•
•

•

•
•
•

3

•
•

•
•

•

•

•

•
•
•

•

•

•
•
•
•
•
••
•

•
•

•

4

5

5

4

3

2

1

•
••
•
•
•••
•
•
• •
•
•
•

•

•
•
•
•
•
•

•

•

•
•
••
••

•

1

•

•
•

••
•
•

•

•
•
•

•

•

2

•

•

•

••
•
•
•
•

•

•
•
•
•

3

•
•
•

•
•
•

•
•

•
•
•

4

•
•
••
•
•
• •

•
•

•
•
•

•
•

•

••
•
•
•

5

FIGURE 14.16. Self-organizing map applied to half-sphere data example. Left
panel is the initial conﬁguration, right panel the ﬁnal one. The 5
5 grid of
prototypes are indicated by circles, and the points that project to each prototype
are plotted randomly within the corresponding circle.

×

14.4 Self-Organizing Maps

531

FIGURE 14.17. Wiremesh representation of the ﬁtted SOM model in IR3. The
lines represent the horizontal and vertical edges of the topological lattice. The
double lines indicate that the surface was folded diagonally back on itself in order
to model the red points. The cluster members have been jittered to indicate their
color, and the purple points are the node centers.

Figure 14.18 shows the reconstruction error, equal to the total sum of
squares of each data point around its prototype. For comparison we carried
out a K-means clustering with 25 centroids, and indicate its reconstruction
error by the horizontal line on the graph. We see that the SOM signiﬁcantly
decreases the error, nearly to the level of the K-means solution. This pro-
vides evidence that the two-dimensional constraint used by the SOM is
reasonable for this particular dataset.

In the batch version of the SOM, we update each mj via

mj =

wkxk
wk

.

P

(14.48)

P
The sum is over points xk that mapped (i.e., were closest to) neighbors mk
of mj. The weight function may be rectangular, that is, equal to 1 for the
as before.
neighbors of mk, or may decrease smoothly with distance
If the neighborhood size is chosen small enough so that it consists only
of mk, with rectangular weights, this reduces to the K-means clustering
procedure described earlier. It can also be thought of as a discrete version
of principal curves and surfaces, described in Section 14.5.

ℓk−
k

ℓjk

532

14. Unsupervised Learning

r
o
r
r

E
n
o
i
t
c
u
r
t
s
n
o
c
e
R

0
5

0
4

0
3

0
2

0
1

0

•

•

•

•

•

••

•

•
•
•
•
•
•
•
•
•••
•
•
•
••••••••••••••••••••••••••••
•

0

500

1000

1500

2000

2500

Iteration

FIGURE 14.18. Half-sphere data: reconstruction error for the SOM as a func-
tion of iteration. Error for k-means clustering is indicated by the horizontal line.

Example: Document Organization and Retrieval

Document retrieval has gained importance with the rapid development of
the Internet and the Web, and SOMs have proved to be useful for organiz-
ing and indexing large corpora. This example is taken from the WEBSOM
homepage http://websom.hut.fi/ (Kohonen et al., 2000). Figure 14.19 rep-
resents a SOM ﬁt to 12,088 newsgroup comp.ai.neural-nets articles. The
labels are generated automatically by the WEBSOM software and provide
a guide as to the typical content of a node.

In applications such as this, the documents have to be reprocessed in
order to create a feature vector. A term-document matrix is created, where
each row represents a single document. The entries in each row are the
relative frequency of each of a predeﬁned set of terms. These terms could
be a large set of dictionary entries (50,000 words), or an even larger set
of bigrams (word pairs), or subsets of these. These matrices are typically
very sparse, and so often some preprocessing is done to reduce the number
of features (columns). Sometimes the SVD (next section) is used to reduce
the matrix; Kohonen et al. (2000) use a randomized variant thereof. These
reduced vectors are then the input to the SOM.

 
14.4 Self-Organizing Maps

533

FIGURE 14.19. Heatmap representation of the SOM model ﬁt to a corpus
of 12,088 newsgroup comp.ai.neural-nets contributions (courtesy WEBSOM
homepage). The lighter areas indicate higher-density areas. Populated nodes are
automatically labeled according to typical content.

534

14. Unsupervised Learning

v1v1v1v1v1v1v1v1

•
•

•
•

•
•

ui1d1
ui1d1
ui1d1
ui1d1
ui1d1
ui1d1
ui1d1
ui1d1

xixixixixixixixi

•
•

•
•

•
•
•
•
•
•
•
•
•

•
•

•
•

•
•

•
•

•
•

•
•

•
•

•
•

•
•

•
•

FIGURE 14.20. The ﬁrst linear principal component of a set of data. The line
minimizes the total squared distance from each point to its orthogonal projection
onto the line.

In this application the authors have developed a “zoom” feature, which
allows one to interact with the map in order to get more detail. The ﬁnal
level of zooming retrieves the actual news articles, which can then be read.

14.5 Principal Components, Curves and Surfaces

Principal components are discussed in Sections 3.4.1, where they shed light
on the shrinkage mechanism of ridge regression. Principal components are
a sequence of projections of the data, mutually uncorrelated and ordered
in variance. In the next section we present principal components as linear
IRp. We then present
manifolds approximating a set of N points xi ∈
some nonlinear generalizations in Section 14.5.2. Other recent proposals
for nonlinear approximating manifolds are discussed in Section 14.9.

14.5.1 Principal Components
The principal components of a set of data in IRp provide a sequence of best
linear approximations to that data, of all ranks q

p.

Denote the observations by x1, x2, . . . , xN , and consider the rank-q linear

≤

model for representing them

14.5 Principal Components, Curves and Surfaces

535

f (λ) = µ + Vqλ,

(14.49)

where µ is a location vector in IRp, Vq is a p
q matrix with q orthogonal
unit vectors as columns, and λ is a q vector of parameters. This is the
parametric representation of an aﬃne hyperplane of rank q. Figures 14.20
and 14.21 illustrate for q = 1 and q = 2, respectively. Fitting such a model
to the data by least squares amounts to minimizing the reconstruction error

×

min
µ,{λi}, Vq

N

i=1
X

xi −
k

µ

−

2.
Vqλik

(14.50)

We can partially optimize for µ and the λi (Exercise 14.7) to obtain

ˆµ = ¯x,
ˆλi = VT

q (xi −

¯x).

This leaves us to ﬁnd the orthogonal matrix Vq:

min
Vq

N

i=1
X

(xi −

||

¯x)

−

VqVT

q (xi −

¯x)

2.

||

(14.51)

(14.52)

(14.53)

For convenience we assume that ¯x = 0 (otherwise we simply replace the
observations by their centered versions ˜xi = xi −
p matrix
Hq = VqVT
q is a projection matrix, and maps each point xi onto its rank-
q reconstruction Hqxi, the orthogonal projection of xi onto the subspace
spanned by the columns of Vq. The solution can be expressed as follows.
p matrix X. We
Stack the (centered) observations into the rows of an N
construct the singular value decomposition of X:

¯x). The p

×

×

X = UDVT .

(14.54)

×

This is a standard decomposition in numerical analysis, and many algo-
rithms exist for its computation (Golub and Van Loan, 1983, for example).
p orthogonal matrix (UT U = Ip) whose columns uj are
Here U is an N
p orthogonal matrix (VT V = Ip)
called the left singular vectors; V is a p
with columns vj called the right singular vectors, and D is a p
p diagonal
0 known as the sin-
matrix, with diagonal elements d1 ≥
gular values. For each rank q, the solution Vq to (14.53) consists of the ﬁrst
q columns of V. The columns of UD are called the principal components
of X (see Section 3.5.1). The N optimal ˆλi in (14.52) are given by the ﬁrst
q principal components (the N rows of the N

×
d2 ≥ · · · ≥

q matrix UqDq).

dp ≥

The one-dimensional principal component line in IR2 is illustrated in Fig-
ure 14.20. For each data point xi, there is a closest point on the line, given
by ui1d1v1. Here v1 is the direction of the line and ˆλi = ui1d1 measures
distance along the line from the origin. Similarly Figure 14.21 shows the

×

×

536

14. Unsupervised Learning

t
n
e
n
o
p
m
o
c

l

i

a
p
c
n
i
r
p

d
n
o
c
e
S

0
.
1

5
.
0

0
.
0

5
.
0
−

0
.
1
−

•
•
•

•

•

•

•

•
•

•
•
• •
•
•
•
•

•
•

•
•
•

•

•

•
•
•

•

•

•

•
•
•

•
•
•
••
•
•
•
•
•• •
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•

•

•

•

•
•

•

•
•
•
• •
•
•
•
•

•

•

•

•

•

•

•

•
•

•

•
•
• •

−1.0

−0.5

0.0

0.5

1.0

First principal component

FIGURE 14.21. The best rank-two linear approximation to the half-sphere data.
The right panel shows the projected points with coordinates given by U2D2, the
ﬁrst two principal components of the data.

two-dimensional principal component surface ﬁt to the half-sphere data
(left panel). The right panel shows the projection of the data onto the
ﬁrst two principal components. This projection was the basis for the initial
conﬁguration for the SOM method shown earlier. The procedure is quite
successful at separating the clusters. Since the half-sphere is nonlinear, a
nonlinear projection will do a better job, and this is the topic of the next
section.

Principal components have many other nice properties, for example, the
linear combination Xv1 has the highest variance among all linear com-
binations of the features; Xv2 has the highest variance among all linear
combinations satisfying v2 orthogonal to v1, and so on.

Example: Handwritten Digits

Principal components are a useful tool for dimension reduction and com-
pression. We illustrate this feature on the handwritten digits data described
in Chapter 1. Figure 14.22 shows a sample of 130 handwritten 3’s, each a
digitized 16
16 grayscale image, from a total of 658 such 3’s. We see
considerable variation in writing styles, character thickness and orienta-
tion. We consider these images as points xi in IR256, and compute their
principal components via the SVD (14.54).

×

Figure 14.23 shows the ﬁrst two principal components of these data. For
each of these ﬁrst two principal components ui1 and ui2, we computed the
5%, 25%, 50%, 75% and 95% quantile points, and used them to deﬁne
the rectangular grid superimposed on the plot. The circled points indicate

 
 
14.5 Principal Components, Curves and Surfaces

537

FIGURE 14.22. A sample of 130 handwritten 3’s shows a variety of writing
styles.

those images close to the vertices of the grid, where the distance measure
focuses mainly on these projected coordinates, but gives some weight to the
components in the orthogonal subspace. The right plot shows the images
corresponding to these circled points. This allows us to visualize the nature
of the ﬁrst two principal components. We see that the v1 (horizontal move-
ment) mainly accounts for the lengthening of the lower tail of the three,
while v2 (vertical movement) accounts for character thickness. In terms of
the parametrized model (14.49), this two-component model has the form

ˆf (λ) = ¯x + λ1v1 + λ2v2

=

+ λ1 ·

+ λ2 ·

.

(14.55)

Here we have displayed the ﬁrst two principal component directions, v1
and v2, as images. Although there are a possible 256 principal components,
approximately 50 account for 90% of the variation in the threes, 12 ac-
count for 63%. Figure 14.24 compares the singular values to those obtained
for equivalent uncorrelated data, obtained by randomly scrambling each
column of X. The pixels in a digitized image are inherently correlated,
and since these are all the same digit the correlations are even stronger.

538

14. Unsupervised Learning

•

•
•

•

•

•

•

•
•
•

•
•
•

•

•

•

•
•

•
•
•
•

•
•

•
•
O

•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•

•
•
•
•
•
•

•
•
•

•
•
•
•

•
•

•
•

•
•
•

•

•

•

•
•

•
•

•
•
•

•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
O

•
•

•

•

•

•

•

•
•

•
•
•
•
O
•
•
•

•

•

•

•
•

•
•
•

•
•
•
•

•

•

•
O
•
•

•

•

•
•

•

•

•
•
•
•
•
•
•
•

•

•
•

•

•

•
O
•
•

•
•
•
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
O
•
•

•

•
•
•
•

•

•

•
O
•

•

•

•

•

•
•
•

•

•

•
•

•

•

•

•

•
•

•

•

•

•

•
O

•

•

•

•
•
•
•
•

•
•
•

•
•
•
•
•
•
•
•
•

•

•
O

•
•
•
•
•
•
•
O
•

•
•
•
•

•

•

•

•

•

•
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•

•

•
•

•
•
•
•
•
•
•
•

•
•
•
•

•
•
•

•
•
•
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
O
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•

•

•

•
•
•
•

•
•

•
•

•
•

•
•
•
•
•
•
•
•
•
•

•
•
O
•

•
•
•

•

•
•
•
•
•
•
•

•
•
•

•

•

•

•

•
•
•
O

•

•
•
•

•
•

•

•
•

•
•
•
•
•
•

•
•
•
O

•
•
O
•

•

•

•

t
n
e
n
o
p
m
o
C

l

i

a
p
c
n
i
r

P
d
n
o
c
e
S

5

0

5
-

-6

-4

-2

0

2

4

6

8

First Principal Component

FIGURE 14.23. (Left panel:) the ﬁrst two principal components of the hand-
written threes. The circled points are the closest projected images to the vertices
of a grid, deﬁned by the marginal quantiles of the principal components. (Right
panel:) The images corresponding to the circled points. These show the nature of
the ﬁrst two principal components.

•

•
••
•
••

s
e
u
a
V

l

l

r
a
u
g
n
S

i

0
8

0
6

0
4

0
2

0

•
•

Real Trace
Randomized Trace

•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

0

50

100

150

200

250

Dimension

FIGURE 14.24. The 256 singular values for the digitized threes, compared to
those for a randomized version of the data (each column of X was scrambled).

 
 
 
14.5 Principal Components, Curves and Surfaces

539

A relatively small subset of the principal components serve as excellent
lower-dimensional features for representing the high-dimensional data.

Example: Procrustes Transformations and Shape Averaging

FIGURE 14.25. (Left panel:) Two diﬀerent digitized handwritten Ss, each rep-
resented by 96 corresponding points in IR2. The green S has been deliberately
rotated and translated for visual eﬀect. (Right panel:) A Procrustes transforma-
tion applies a translation and rotation to best match up the two set of points.

Figure 14.25 represents two sets of points, the orange and green, in the
same plot. In this instance these points represent two digitized versions
of a handwritten S, extracted from the signature of a subject “Suresh.”
Figure 14.26 shows the entire signatures from which these were extracted
(third and fourth panels). The signatures are recorded dynamically using
touch-screen devices, familiar sights in modern supermarkets. There are
N = 96 points representing each S, which we denote by the N
2 matrices
X1 and X2. There is a correspondence between the points—the ith rows
of X1 and X2 are meant to represent the same positions along the two S’s.
In the language of morphometrics, these points represent landmarks on
the two objects. How one ﬁnds such corresponding landmarks is in general
diﬃcult and subject speciﬁc. In this particular case we used dynamic time
warping of the speed signal along each signature (Hastie et al., 1992), but
will not go into details here.

×

In the right panel we have applied a translation and rotation to the green
points so as best to match the orange—a so-called Procrustes3 transforma-
tion (Mardia et al., 1979, for example).

Consider the problem

min
µ,R ||

X2 −

(X1R + 1µT )

||F ,

(14.56)

3Procrustes was an African bandit in Greek mythology, who stretched or squashed

his visitors to ﬁt his iron bed (eventually killing them).

540

14. Unsupervised Learning

×

with X1 and X2 both N
thonormal p

p matrices of corresponding points, R an or-
p matrix4, and µ a p-vector of location coordinates. Here

×

F = trace(XT X) is the squared Frobenius matrix norm.
2

X
||
||
Let ¯x1 and ¯x2 be the column mean vectors of the matrices, and ˜X1 and
˜X2 be the versions of these matrices with the means removed. Consider
˜X2 = UDVT . Then the solution to (14.56) is given by (Exer-
the SVD ˜XT
1
cise 14.8)

ˆR = UVT
ˆµ = ¯x2 −

ˆR¯x1,

(14.57)

and the minimal distances is referred to as the Procrustes distance. From
the form of the solution, we can center each matrix at its column centroid,
and then ignore location completely. Hereafter we assume this is the case.

The Procrustes distance with scaling solves a slightly more general

problem,

min
β,R ||

X2 −

βX1R

||F ,

(14.58)

where β > 0 is a positive scalar. The solution for R is as before, with
ˆβ = trace(D)/
||

Related to Procrustes distance is the Procrustes average of a collection

X1||
of L shapes, which solves the problem

2
F .

min
{Rℓ}L

1 ,M

L

Xℓ=1

XℓRℓ −

||

M

2
F ;

||

(14.59)

that is, ﬁnd the shape M closest in average squared Procrustes distance to
all the shapes. This is solved by a simple alternating algorithm:

0. Initialize M = X1 (for example).

1. Solve the L Procrustes rotation problems with M ﬁxed, yielding

X ˆRℓ.

X′

ℓ ←
2. Let M

1
L

←

L
ℓ=1 X′
ℓ.

Steps 1. and 2. are repeated until the criterion (14.59) converges.

P

Figure 14.26 shows a simple example with three shapes. Note that we can
only expect a solution up to a rotation; alternatively, we can impose a
constraint, such as that M be upper-triangular, to force uniqueness. One
can easily incorporate scaling in the deﬁnition (14.59); see Exercise 14.9.

Most generally we can deﬁne the aﬃne-invariant average of a set of

shapes via

4To simplify matters, we consider only orthogonal matrices which include reﬂections
as well as rotations [the O(p) group]; although reﬂections are unlikely here, these methods
can be restricted further to allow only rotations [SO(p) group].

14.5 Principal Components, Curves and Surfaces

541

FIGURE 14.26. The Procrustes average of three versions of the leading S in
Suresh’s signatures. The left panel shows the preshape average, with each of the
shapes X′
ℓ in preshape space superimposed. The right three panels map the pre-
shape M separately to match each of the original S’s.

L

min
{Aℓ}L

1 ,M

Xℓ=1

XℓAℓ −

||

M

2
F ,

||

(14.60)

where the Aℓ are any p
p nonsingular matrices. Here we require a stan-
dardization, such as MT M = I, to avoid a trivial solution. The solution is
attractive, and can be computed without iteration (Exercise 14.10):

×

1. Let Hℓ = Xℓ(XT

ℓ Xℓ)−1XT

ℓ be the rank-p projection matrix deﬁned

p matrix formed from the p largest eigenvectors of ¯H =

by Xℓ.

2. M is the N
×
L
ℓ=1 Hℓ.

1
L

P

14.5.2 Principal Curves and Surfaces

Principal curves generalize the principal component line, providing a smooth
one-dimensional curved approximation to a set of data points in IRp. A prin-
cipal surface is more general, providing a curved manifold approximation
of dimension 2 or more.

We will ﬁrst deﬁne principal curves for random variables X

IRp, and
then move to the ﬁnite data case. Let f (λ) be a parameterized smooth
curve in IRp. Hence f (λ) is a vector function with p coordinates, each a
smooth function of the single parameter λ. The parameter λ can be chosen,
for example, to be arc-length along the curve from some ﬁxed origin. For
each data value x, let λf (x) deﬁne the closest point on the curve to x. Then
f (λ) is called a principal curve for the distribution of the random vector
X if

∈

f (λ) = E(X

λf (X) = λ).

|

(14.61)

This says f (λ) is the average of all data points that project to it, that is, the
points for which it is “responsible.” This is also known as a self-consistency
property. Although in practice, continuous multivariate distributes have
inﬁnitely many principal curves (Duchamp and Stuetzle, 1996), we are

542

14. Unsupervised Learning

•
•

•
•

•
•

•
•

•
•
•
•

•
•

•
•

•
•

•
•

•
•
•
•
•
•

• •
• •
•
•
•
•

•
•

•
•

•
•

•
•

.....
....

•
•

•
•

•
•

•
•

•
•

•
•

f (λ) = [f1(λ), f2(λ)]
f (λ) = [f1(λ), f2(λ)]
f (λ) = [f1(λ), f2(λ)]
f (λ) = [f1(λ), f2(λ)]
f (λ) = [f1(λ), f2(λ)]
f (λ) = [f1(λ), f2(λ)]
f (λ) = [f1(λ), f2(λ)]
f (λ) = [f1(λ), f2(λ)]
f (λ) = [f1(λ), f2(λ)]

•
•

•
•

•
•

•
•

FIGURE 14.27. The principal curve of a set of data. Each point on the curve
is the average of all data points that project there.

interested mainly in the smooth ones. A principal curve is illustrated in
Figure 14.27.

Principal points are an interesting related concept. Consider a set of k
prototypes and for each point x in the support of a distribution, identify
the closest prototype, that is, the prototype that is responsible for it. This
induces a partition of the feature space into so-called Voronoi regions. The
set of k points that minimize the expected distance from X to its prototype
are called the principal points of the distribution. Each principal point is
self-consistent, in that it equals the mean of X in its Voronoi region. For
example, with k = 1, the principal point of a circular normal distribution is
the mean vector; with k = 2 they are a pair of points symmetrically placed
on a ray through the mean vector. Principal points are the distributional
analogs of centroids found by K-means clustering. Principal curves can be
viewed as k =
principal points, but constrained to lie on a smooth curve,
in a similar way that a SOM constrains K-means cluster centers to fall on
a smooth manifold.

∞

To ﬁnd a principal curve f (λ) of a distribution, we consider its coordinate
functions f (λ) = [f1(λ), f2(λ), . . . , fp(λ)] and let X T = (X1, X2, . . . , Xp).
Consider the following alternating steps:

(a)
(b)

ˆfj(λ)
ˆλf (x)

←
←

E(Xj|
argminλ′

x

||

−

ˆf (λ′)

2.

||

λ(X) = λ); j = 1, 2, . . . , p,

(14.62)

The ﬁrst equation ﬁxes λ and enforces the self-consistency requirement
(14.61). The second equation ﬁxes the curve and ﬁnds the closest point on

14.5 Principal Components, Curves and Surfaces

543

2
.
0

1
.
0

0
.
0

2
λ

•
•

1
.
0
-

2
.
0
-

•
•
•

•

•

•

•

•

•
•
•

•

•
•

•
•
•
•

•

•
•
•

•

•

•
•

•

•

•

•

•

•
•

•
•
•

•
•
•
•
•
••
•
•
••
•
•
•
•
•
•
•
•
•
•

•

•
•

•
•
•
•

-0.1

0.0
λ1

•

•

•

•

•
•

•
•

•

0.1

•

•

•
•

•

•

•

•
•
•

•
•
•
•

•

0.2

FIGURE 14.28. Principal surface ﬁt to half-sphere data. (Left panel:) ﬁtted
two-dimensional surface. (Right panel:) projections of data points onto the sur-
face, resulting in coordinates ˆλ1, ˆλ2.

the curve to each data point. With ﬁnite data, the principal curve algorithm
starts with the linear principal component, and iterates the two steps in
(14.62) until convergence. A scatterplot smoother is used to estimate the
conditional expectations in step (a) by smoothing each Xj as a function of
the arc-length ˆλ(X), and the projection in (b) is done for each of the ob-
served data points. Proving convergence in general is diﬃcult, but one can
show that if a linear least squares ﬁt is used for the scatterplot smoothing,
then the procedure converges to the ﬁrst linear principal component, and
is equivalent to the power method for ﬁnding the largest eigenvector of a
matrix.

Principal surfaces have exactly the same form as principal curves, but
are of higher dimension. The mostly commonly used is the two-dimensional
principal surface, with coordinate functions

f (λ1, λ2) = [f1(λ1, λ2), . . . , fp(λ1, λ2)].

The estimates in step (a) above are obtained from two-dimensional surface
smoothers. Principal surfaces of dimension greater than two are rarely used,
since the visualization aspect is less attractive, as is smoothing in high
dimensions.

Figure 14.28 shows the result of a principal surface ﬁt to the half-sphere
data. Plotted are the data points as a function of the estimated nonlinear
coordinates ˆλ1(xi), ˆλ2(xi). The class separation is evident.

Principal surfaces are very similar to self-organizing maps. If we use a
kernel surface smoother to estimate each coordinate function fj(λ1, λ2),
this has the same form as the batch version of SOMs (14.48). The SOM
weights wk are just the weights in the kernel. There is a diﬀerence, however:

544

14. Unsupervised Learning

the principal surface estimates a separate prototype f (λ1(xi), λ2(xi)) for
each data point xi, while the SOM shares a smaller number of prototypes
for all data points. As a result, the SOM and principal surface will agree
only as the number of SOM prototypes grows very large.

There also is a conceptual diﬀerence between the two. Principal sur-
faces provide a smooth parameterization of the entire manifold in terms
of its coordinate functions, while SOMs are discrete and produce only the
estimated prototypes for approximating the data. The smooth parameter-
ization in principal surfaces preserves distance locally: in Figure 14.28 it
reveals that the red cluster is tighter than the green or blue clusters. In
simple examples the estimates coordinate functions themselves can be in-
formative: see Exercise 14.13.

14.5.3 Spectral Clustering

Traditional clustering methods like K-means use a spherical or elliptical
metric to group data points. Hence they will not work well when the clus-
ters are non-convex, such as the concentric circles in the top left panel of
Figure 14.29. Spectral clustering is a generalization of standard clustering
methods, and is designed for these situations. It has close connections with
the local multidimensional-scaling techniques (Section 14.9) that generalize
MDS.

i

h

×

V, E

The starting point is a N

N matrix of pairwise similarities sii′

0 be-
tween all observation pairs. We represent the observations in an undirected
similarity graph G =
. The N vertices vi represent the observations,
and pairs of vertices are connected by an edge if their similarity is positive
(or exceeds some threshold). The edges are weighted by the sii′ . Clustering
is now rephrased as a graph-partition problem, where we identify connected
components with clusters. We wish to partition the graph, such that edges
between diﬀerent groups have low weight, and within a group have high
weight. The idea in spectral clustering is to construct similarity graphs that
represent the local neighborhood relationships between observations.

≥

IRp, and let
To make things more concrete, consider a set of N points xi ∈
dii′ be the Euclidean distance between xi and xi′. We will use as similarity
d2
matrix the radial-kernel gram matrix; that is, sii′ = exp(
ii′ /c), where
c > 0 is a scale parameter.

−

There are many ways to deﬁne a similarity matrix and its associated
similarity graph that reﬂect local behavior. The most popular is the mutual
NK to be the symmetric set of nearby
K-nearest-neighbor graph. Deﬁne
pairs of points; speciﬁcally a pair (i, i′) is in
NK if point i is among the
K-nearest neighbors of i′, or vice-versa. Then we connect all symmetric
nearest neighbors, and give them edge weight wii′ = sii′ ; otherwise the
edge weight is zero. Equivalently we set to zero all the pairwise similarities
NK, and draw the graph for this modiﬁed similarity matrix.
not in

14.5 Principal Components, Curves and Surfaces

545

Alternatively, a fully connected graph includes all pairwise edges with
weights wii′ = sii′ , and the local behavior is controlled by the scale param-
eter c.

The matrix of edge weights W =

from a similarity graph is called
i′ wii′ , the sum of
the adjacency matrix. The degree of vertex i is gi =
the weights of the edges connected to it. Let G be a diagonal matrix with
diagonal elements gi.

wii′
{

P

}

Finally, the graph Laplacian is deﬁned by

L = G

W

(14.63)

−
This is called the unnormalized graph Laplacian; a number of normalized
versions have been proposed—these standardize the Laplacian with respect
to the node degrees gi, for example, ˜L = I

G−1W.

Spectral clustering ﬁnds the m eigenvectors ZN ×m corresponding to the
m smallest eigenvalues of L (ignoring the trivial constant eigenvector).
Using a standard method like K-means, we then cluster the rows of Z to
yield a clustering of the original data points.

−

An example is presented in Figure 14.29. The top left panel shows 450
simulated data points in three circular clusters indicated by the colors. K-
means clustering would clearly have diﬃculty identifying the outer clusters.
We applied spectral clustering using a 10-nearest neighbor similarity graph,
and display the eigenvector corresponding to the second and third smallest
eigenvalue of the graph Laplacian in the lower left. The 15 smallest eigen-
values are shown in the top right panel. The two eigenvectors shown have
identiﬁed the three clusters, and a scatterplot of the rows of the eigenvector
matrix Y in the bottom right clearly separates the clusters. A procedure
such as K-means clustering applied to these transformed points would eas-
ily identify the three groups.

Why does spectral clustering work? For any vector f we have

N

N

N

f T Lf =

=

gif 2

i −

N

i=1
X
N
1
2

Xi′=1
i=1
X
wii′ (fi −

fifi′ wii′

fi′ )2.

(14.64)

i=1
X

Xi′=1
Formula 14.64 suggests that a small value of f T Lf will be achieved if pairs
of points with large adjacencies have coordinates fi and fi′ close together.
Since 1T L1 = 0 for any graph, the constant vector is a trivial eigenvector
with eigenvalue zero. Not so obvious is the fact that if the graph is con-
nected5, it is the only zero eigenvector (Exercise 14.21). Generalizing this
argument, it is easy to show that for a graph with m connected components,

5A graph is connected if any two nodes can be reached via a path of connected nodes.

546

14. Unsupervised Learning

4

2

2
x

0

2
−

4
−

5
0
.
0

5
0
.
0
−

5
0
.
0

5
0
.
0
−

t
s
e

l
l

a
m
S
d
n
2

t
s
e

l
l

a
m
S
d
r
3

l

e
u
a
v
n
e
g
E

i

5
.
0

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

−4

−2

0

x1

2

4

1

3

5

10

15

Number

Eigenvectors

Spectral Clustering

r
o
t
c
e
v
n
e
g
E

i

t
s
e

l
l

a
m
S
d
r
i
h
T

6
0
.
0

2
0
.
0

2
0
.
0
−

6
0
.
0
−

0

100

200

300

400

−0.04

−0.02

0.00

0.02

Index

Second Smallest Eigenvector

FIGURE 14.29. Toy example illustrating spectral clustering. Data in top left are
450 points falling in three concentric clusters of 150 points each. The points are
uniformly distributed in angle, with radius 1, 2.8 and 5 in the three groups, and
Gaussian noise with standard deviation 0.25 added to each point. Using a k = 10
nearest-neighbor similarity graph, the eigenvector corresponding to the second and
third smallest eigenvalues of L are shown in the bottom left; the smallest eigen-
vector is constant. The data points are colored in the same way as in the top left.
The 15 smallest eigenvalues are shown in the top right panel. The coordinates of
the 2nd and 3rd eigenvectors (the 450 rows of Z) are plotted in the bottom right
panel. Spectral clustering does standard (e.g., K-means) clustering of these points
and will easily recover the three original clusters.

 
 
 
 
 
 
14.5 Principal Components, Curves and Surfaces

547

the nodes can be reordered so that L is block diagonal with a block for each
connected component. Then L has m eigenvectors of eigenvalue zero, and
the eigenspace of eigenvalue zero is spanned by the indicator vectors of the
connected components. In practice one has strong and weak connections,
so zero eigenvalues are approximated by small eigenvalues.

Spectral clustering is an interesting approach for ﬁnding non-convex clus-
ters. When a normalized graph Laplacian is used, there is another way to
view this method. Deﬁning P = G−1W, we consider a random walk on
the graph with transition probability matrix P. Then spectral clustering
yields groups of nodes such that the random walk seldom transitions from
one group to another.

There are a number of issues that one must deal with in applying spec-
tral clustering in practice. We must choose the type of similarity graph—eg.
fully connected or nearest neighbors, and associated parameters such as the
number of nearest of neighbors k or the scale parameter of the kernel c. We
must also choose the number of eigenvectors to extract from L and ﬁnally,
as with all clustering methods, the number of clusters. In the toy example
of Figure 14.29 we obtained good results for k
[5, 200], the value 200 cor-
responding to a fully connected graph. With k < 5 the results deteriorated.
Looking at the top-right panel of Figure 14.29, we see no strong separation
between the smallest three eigenvalues and the rest. Hence it is not clear
how many eigenvectors to select.

∈

14.5.4 Kernel Principal Components

Spectral clustering is related to kernel principal components, a non-linear
version of linear principal components. Standard linear principal compo-
nents (PCA) are obtained from the eigenvectors of the covariance matrix,
and give directions in which the data have maximal variance. Kernel PCA
(Sch¨olkopf et al., 1999) expand the scope of PCA, mimicking what we would
obtain if we were to expand the features by non-linear transformations, and
then apply PCA in this transformed feature space.

We show in Section 18.5.2 that the principal components variables Z of
a data matrix X can be computed from the inner-product (gram) matrix
K = XXT . In detail, we compute the eigen-decomposition of the double-
centered version of the gram matrix

K = (I

M)K(I

M) = UD2UT ,

(14.65)

−
with M = 11T /N , and then Z = UD. Exercise 18.15 shows how to com-
pute the projections of new observations in this space.

−

e

K(xi, xi′ )
{
φ(xi), φ(xi′ )

Kernel PCA simply mimics this procedure, interpreting the kernel ma-
trix K =
as an inner-product matrix of the implicit fea-
tures
and ﬁnding its eigenvectors. The elements of the mth
component zm (mth column of Z) can be written (up to centering) as
N
zim =
j=1 αjmK(xi, xj), where αjm = ujm/dm (Exercise 14.16).

}

i

h

P

548

14. Unsupervised Learning

We can gain more insight into kernel PCA by viewing the zm as sam-
HK the
ple evaluations of principal component functions gm ∈ HK, with
reproducing kernel Hilbert space generated by K (see Section 5.8.1). The
ﬁrst principal component function g1 solves

max
g1∈HK

VarT g1(X) subject to

g1||HK = 1

||

(14.66)

T

||

Here VarT refers to the sample variance over training data
. The norm
g1||HK = 1 controls the size and roughness of the function g1,
constraint
as dictated by the kernel K. As in the regression case it can be shown that
the solution to (14.66) is ﬁnite dimensional with representation g1(x) =
N
j=1 cjK(x, xj). Exercise 14.17 shows that the solution is deﬁned by ˆcj =
αj1, j = 1, . . . , N above. The second principal component function is de-
P
g1, g2iHK = 0,
ﬁned in a similar way, with the additional constraint that
and so on.6
Sch¨olkopf et al. (1999) demonstrate the use of kernel principal compo-
nents as features for handwritten-digit classiﬁcation, and show that they
can improve the performance of a classiﬁer when these are used instead of
linear principal components.

h

Note that if we use the radial kernel

K(x, x′) = exp(

x

−k

x′

2/c),
k

−

(14.67)

then the kernel matrix K has the same form as the similarity matrix S in
spectral clustering. The matrix of edge weights W is a localized version of
K, setting to zero all similarities for pairs of points that are not nearest
neighbors.

Kernel PCA ﬁnds the eigenvectors corresponding to the largest eigenval-
K; this is equivalent to ﬁnding the eigenvectors corresponding to the

ues of
smallest eigenvalues of

e

K.

I

−

(14.68)

This is almost the same as the Laplacian (14.63), the diﬀerences being the
e
K and the fact that G has the degrees of the nodes along the
centering of
diagonal.

e

Figure 14.30 examines the performance of kernel principal components
in the toy example of Figure 14.29. In the upper left panel we used the ra-
dial kernel with c = 2, the same value that was used in spectral clustering.
This does not separate the groups, but with c = 10 (upper right panel), the
ﬁrst component separates the groups well. In the lower-left panel we ap-
plied kernel PCA using the nearest-neighbor radial kernel W from spectral
clustering. In the lower right panel we use the kernel matrix itself as the

6This section beneﬁted from helpful discussions with Jonathan Taylor.

14.5 Principal Components, Curves and Surfaces

549

Radial Kernel (c=2)

Radial Kernel (c=10)

r
o
t
c
e
v
n
e
g
E

i

t
s
e
g
r
a
L

d
n
o
c
e
S

5
0
.
0

0
0
.
0

5
0
.
0
−

−0.10

−0.06

−0.02

0.02

−0.06

−0.02

0.02

0.06

First Largest Eigenvector

First Largest Eigenvector

NN Radial Kernel (c=2)

Radial Kernel Laplacian (c=2)

r
o
t
c
e
v
n
e
g
E

i

t
s
e

l
l

a
m
S
d
r
i
h
T

5
1
.
0

0
1
.
0

5
0
.
0

0
0
.
0

0
1
.
0
−

r
o
t
c
e
v
n
e
g
E

i

t
s
e
g
r
a
L

d
n
o
c
e
S

r
o
t
c
e
v
n
e
g
E

i

t
s
e
g
r
a
L

d
n
o
c
e
S

0
1
.
0

5
0
.
0

0
0
.
0

5
0

.
0
−

0
1
.
0
−

2
.
0

1
.
0

0
.
0

1
.
0
−

2
.
0
−

0.00

0.05

0.10

0.15

−0.05

0.00

0.05

0.10

0.15

First Largest Eigenvector

Second Smallest Eigenvector

FIGURE 14.30. Kernel principal components applied to the toy example of Fig-
ure 14.29, using diﬀerent kernels. (Top left:) Radial kernel (14.67) with c = 2.
(Top right:) Radial kernel with c = 10. (Bottom left): Nearest neighbor radial ker-
nel W from spectral clustering. (Bottom right:) Spectral clustering with Laplacian
constructed from the radial kernel.

 
 
 
 
 
 
 
 
550

14. Unsupervised Learning

similarity matrix for constructing the Laplacian (14.63) in spectral cluster-
ing. In neither case do the projections separate the two groups. Adjusting
c did not help either.

In this toy example, we see that kernel PCA is quite sensitive to the scale
and nature of the kernel. We also see that the nearest-neighbor truncation
of the kernel is important for the success of spectral clustering.

14.5.5 Sparse Principal Components

We often interpret principal components by examining the direction vectors
vj, also known as loadings, to see which variables play a role. We did this
with the image loadings in (14.55). Often this interpretation is made easier
if the loadings are sparse. In this section we brieﬂy discuss some methods
for deriving principal components with sparse loadings. They are all based
on lasso (L1) penalties.
We start with an N

p data matrix X, with centered columns. The
proposed methods focus on either the maximum-variance property of prin-
cipal components, or the minimum reconstruction error. The SCoTLASS
procedure of Joliﬀe et al. (2003) takes the ﬁrst approach, by solving

×

max vT (XT X)v, subject to

p
j=1 |

vj| ≤

t, vT v = 1.

(14.69)

P
The absolute-value constraint encourages some of the loadings to be zero
and hence v to be sparse. Further sparse principal components are found
in the same way, by forcing the kth component to be orthogonal to the
ﬁrst k
1 components. Unfortunately this problem is not convex and the
computations are diﬃcult.

−

Zou et al. (2006) start instead with the regression/reconstruction prop-
erty of PCA, similar to the approach in Section 14.5.1. Let xi be the ith row
of X. For a single component, their sparse principal component technique
solves

min
θ,v

N

i=1
X

xi −

||

θvT xi||

2
2 + λ

v

||

||

2

||
Let’s examine this formulation in more detail.

subject to

v

2 + λ1||
θ

||1
||2 = 1.

(14.70)

If both λ and λ1 are zero and N > p, it is easy to show that v = θ
and is the largest principal component direction.

When p
N the solution is not necessarily unique unless λ > 0. For
any λ > 0 and λ1 = 0 the solution for v is proportional to the largest
principal component direction.

≫

The second penalty on v encourages sparseness of the loadings.

•

•

•

14.5 Principal Components, Curves and Surfaces

551

Walking Speed

Verbal Fluency

Principal Components

Sparse Principal Components

FIGURE 14.31. Standard and sparse principal components from a study of
the corpus callosum variation. The shape variations corresponding to signiﬁcant
principal components (red curves) are overlaid on the mean CC shape (black
curves).

For multiple components, the sparse principal components procedures

minimizes

N

xi −

||

ΘVT xi||

K

2 + λ

i=1
X

Xk=1
subject to ΘT Θ = IK. Here V is a p
is also p

K.

×

||

2
2 +

vk||

K

Xk=1

λ1k||

vk||1,

(14.71)

K matrix with columns vk and Θ

×

Criterion (14.71) is not jointly convex in V and Θ, but it is convex in
each parameter with the other parameter ﬁxed7. Minimization over V with
Θ ﬁxed is equivalent to K elastic net problems (Section 18.4) and can be
done eﬃciently. On the other hand, minimization over Θ with V ﬁxed is a
version of the Procrustes problem (14.56), and is solved by a simple SVD
calculation (Exercise 14.12). These steps are alternated until convergence.
Figure 14.31 shows an example of sparse principal components analysis
using (14.71), taken from Sj¨ostrand et al. (2007). Here the shape of the
mid-sagittal cross-section of the corpus callosum (CC) is related to various
clinical parameters in a study involving 569 elderly persons8. In this exam-

7Note that the usual principal component criterion, for example (14.50), is not jointly
convex in the parameters either. Nevertheless, the solution is well deﬁned and an eﬃcient
algorithm is available.

8We thank Rasmus Larsen and Karl Sj¨ostrand for suggesting this application, and

supplying us with the postscript ﬁgures reproduced here.

552

14. Unsupervised Learning

FIGURE 14.32. An example of a mid-saggital brain slice, with the corpus col-
losum annotated with landmarks.

ple PCA is applied to shape data, and is a popular tool in morphometrics.
For such applications, a number of landmarks are identiﬁed along the cir-
cumference of the shape; an example is given in Figure 14.32. These are
aligned by Procrustes analysis to allow for rotations, and in this case scal-
ing as well (see Section 14.5.1). The features used for PCA are the sequence
of coordinate pairs for each landmark, unpacked into a single vector.

In this analysis, both standard and sparse principal components were
computed, and components that were signiﬁcantly associated with various
clinical parameters were identiﬁed. In the ﬁgure, the shape variations cor-
responding to signiﬁcant principal components (red curves) are overlaid on
the mean CC shape (black curves). Low walking speed relates to CCs that
are thinner (displaying atrophy) in regions connecting the motor control
and cognitive centers of the brain. Low verbal ﬂuency relates to CCs that
are thinner in regions connecting auditory/visual/cognitive centers. The
sparse principal components procedure gives a more parsimonious, and po-
tentially more informative picture of the important diﬀerences.

14.6 Non-negative Matrix Factorization

553

14.6 Non-negative Matrix Factorization

Non-negative matrix factorization (Lee and Seung, 1999) is a recent al-
ternative approach to principal components analysis, in which the data
and components are assumed to be non-negative. It is useful for modeling
non-negative data such as images.

The N

×

p data matrix X is approximated by

X

r and H is r

×

WH

p, r

≤

≈

×

(14.72)

max(N, p). We assume that

where W is N
0.
xij, wik, hkj ≥

The matrices W and H are found by maximizing

L(W, H) =

N

p

i=1
X

j=1
X

[xij log(WH)ij −

(WH)ij].

(14.73)

This is the log-likelihood from a model in which xij has a Poisson dis-

tribution with mean (WH)ij—quite reasonable for positive data.

The following alternating algorithm (Lee and Seung, 2001) converges to

a local maximum of L(W, H):

wik ←

wik

P

hkj ←

hkj

P

p
j=1 hkjxij/(WH)ij
p
j=1 hkj
N
i=1 wikxij/(WH)ij
N
i=1 wik

P

(14.74)

This algorithm can be derived as a minorization procedure for maximizing
L(W, H) (Exercise 14.23) and is also related to the iterative-proportional-
scaling algorithm for log-linear models (Exercise 14.24).

P

Figure 14.33 shows an example taken from Lee and Seung (1999)9, com-
paring non-negative matrix factorization (NMF), vector quantization (VQ,
equivalent to k-means clustering) and principal components analysis (PCA).
The three learning methods were applied to a database of N = 2, 429 fa-
cial images, each consisting of 19
381
×
matrix X. As shown in the 7
19 image),
each method has learned a set of r = 49 basis images. Positive values are
illustrated with black pixels and negative values with red pixels. A par-
ticular instance of a face, shown at top right, is approximated by a linear
superposition of basis images. The coeﬃcients of the linear superposition
7 array10, and the resulting su-
are shown next to each montage, in a 7
perpositions are shown to the right of the equality sign. The authors point

19 pixels, resulting in a 2, 429

7 array of montages (each a 19

×

×

×

×

9We thank Sebastian Seung for providing this image.
10These 7 × 7 arrangements allow for a compact display, and have no structural

signiﬁcance.

554

14. Unsupervised Learning

out that unlike VQ and PCA, NMF learns to represent faces with a set of
basis images resembling parts of faces.

Donoho and Stodden (2004) point out a potentially serious problem with
non-negative matrix factorization. Even in situations where X = WH holds
exactly, the decomposition may not be unique. Figure 14.34 illustrates the
problem. The data points lie in p = 2 dimensions, and there is “open space”
between the data and the coordinate axes. We can choose the basis vectors
h1 and h2 anywhere in this open space, and represent each data point
exactly with a nonnegative linear combination of these vectors. This non-
uniqueness means that the solution found by the above algorithm depends
on the starting values, and it would seem to hamper the interpretability of
the factorization. Despite this interpretational drawback, the non-negative
matrix factorization and its applications has attracted a lot of interest.

14.6.1 Archetypal Analysis

This method, due to Cutler and Breiman (1994), approximates data points
by prototypes that are themselves linear combinations of data points. In
this sense it has a similar ﬂavor to K-means clustering. However, rather
than approximating each data point by a single nearby prototype, archety-
pal analysis approximates each data point by a convex combination of a
collection of prototypes. The use of a convex combination forces the proto-
types to lie on the convex hull of the data cloud. In this sense, the prototypes
are “pure,”, or “archetypal.”

As in (14.72), the N

×

p data matrix X is modeled as

WH

X

≈

(14.75)

r and H is r

r
where W is N
k=1 wik =
i. Hence the N data points (rows of X) in p-dimensional space are
1
represented by convex combinations of the r archetypes (rows of H). We
also assume that

p. We assume that wik ≥

0 and

P

×

×

∀

H = BX

(14.76)

where B is r
k. Thus the archetypes
themselves are convex combinations of the data points. Using both (14.75)
P
and (14.76) we minimize

N with bki ≥

0 and

×

∀

N
i=1 bki = 1

J(W, B) =
=

X
X

2

WH
||
WBX

||
||
over the weights W and B. This function is minimized in an alternating
fashion, with each separate minimization involving a convex optimization.
The overall problem is not convex however, and so the algorithm converges
to a local minimum of the criterion.

(14.77)

−
−

||

2

14.6 Non-negative Matrix Factorization

555

Original

NMF

VQ

PCA

=

=

=

FIGURE 14.33. Non-negative matrix factorization (NMF), vector quantization
(VQ, equivalent to k-means clustering) and principal components analysis (PCA)
applied to a database of facial images. Details are given in the text. Unlike VQ
and PCA, NMF learns to represent faces with a set of basis images resembling
parts of faces.

·
(cid:13)
·
(cid:13)
·
(cid:13)
556

14. Unsupervised Learning

h1

h2

FIGURE 14.34. Non-uniqueness of the non-negative matrix factorization.
There are 11 data points in two dimensions. Any choice of the basis vectors h1
and h2 in the open space between the coordinate axes and data, gives an exact
reconstruction of the data.

Figure 14.35 shows an example with simulated data in two dimensions.
The top panel displays the results of archetypal analysis, while the bottom
panel shows the results from K-means clustering. In order to best recon-
struct the data from convex combinations of the prototypes, it pays to
locate the prototypes on the convex hull of the data. This is seen in the top
panels of Figure 14.35 and is the case in general, as proven by Cutler and
Breiman (1994). K-means clustering, shown in the bottom panels, chooses
prototypes in the middle of the data cloud.

We can think of K-means clustering as a special case of the archetypal
model, in which each row of W has a single one and the rest of the entries
are zero.

Notice also that the archetypal model (14.75) has the same general form
as the non-negative matrix factorization model (14.72). However, the two
models are applied in diﬀerent settings, and have somewhat diﬀerent goals.
Non-negative matrix factorization aims to approximate the columns of the
data matrix X, and the main output of interest are the columns of W
representing the primary non-negative components in the data. Archetypal
analysis focuses instead on the approximation of the rows of X using the
rows of H, which represent the archetypal data points. Non-negative matrix
factorization also assumes that r
p. With r = p, we can get an exact
reconstruction simply choosing W to be the data X with columns scaled
so that they sum to 1. In contrast, archetypal analysis requires r
N ,
but allows r > p. In Figure 14.35, for example, p = 2, N = 50 while
r = 2, 4 or 8. The additional constraint (14.76) implies that the archetypal
approximation will not be perfect, even if r > p.

≤

≤

Figure 14.36 shows the results of archetypal analysis applied to the
database of 3’s displayed in Figure 14.22. The three rows in Figure 14.36
are the resulting archetypes from three runs, specifying two, three and four

14.7 Independent Component Analysisand Exploratory Projection Pursuit

557

2 Prototypes

4 Prototypes

8 Prototypes

FIGURE 14.35. Archetypal analysis (top panels) and K-means clustering (bot-
tom panels) applied to 50 data points drawn from a bivariate Gaussian distribu-
tion. The colored points show the positions of the prototypes in each case.

archetypes, respectively. As expected, the algorithm has produced extreme
3’s both in size and shape.

14.7

Independent Component Analysis and
Exploratory Projection Pursuit

Multivariate data are often viewed as multiple indirect measurements aris-
ing from an underlying source, which typically cannot be directly measured.
Examples include the following:

•

•

Educational and psychological tests use the answers to questionnaires
to measure the underlying intelligence and other mental abilities of
subjects.

EEG brain scans measure the neuronal activity in various parts of
the brain indirectly via electromagnetic signals recorded at sensors
placed at various positions on the head.

•

The trading prices of stocks change constantly over time, and reﬂect
various unmeasured factors such as market conﬁdence, external in-

558

14. Unsupervised Learning

FIGURE 14.36. Archetypal analysis applied to the database of digitized 3’s. The
rows in the ﬁgure show the resulting archetypes from three runs, specifying two,
three and four archetypes, respectively.

ﬂuences, and other driving forces that may be hard to identify or
measure.

Factor analysis is a classical technique developed in the statistical liter-
ature that aims to identify these latent sources. Factor analysis models
are typically wed to Gaussian distributions, which has to some extent hin-
dered their usefulness. More recently, independent component analysis has
emerged as a strong competitor to factor analysis, and as we will see, relies
on the non-Gaussian nature of the underlying sources for its success.

14.7.1 Latent Variables and Factor Analysis

The singular-value decomposition X = UDVT (14.54) has a latent variable
representation. Writing S = √N U and AT = DVT /√N , we have X =
SAT , and hence each of the columns of X is a linear combination of the
columns of S. Now since U is orthogonal, and assuming as before that the
columns of X (and hence U) each have mean zero, this implies that the
columns of S have zero mean, are uncorrelated and have unit variance. In
terms of random variables, we can interpret the SVD, or the corresponding
principal component analysis (PCA) as an estimate of a latent variable
model

14.7 Independent Component Analysis and Exploratory Projection Pursuit

559

X1 = a11S1 + a12S2 +
X2 = a21S1 + a22S2 +
...
Xp = ap1S1 + ap2S2 +

...

+ a1pSp
+ a2pSp

+ appSp,

· · ·
· · ·

· · ·

(14.78)

or simply X = AS. The correlated Xj are each represented as a linear
expansion in the uncorrelated, unit variance variables Sℓ. This is not too
p matrix R, we can
satisfactory, though, because given any orthogonal p
write

×

X = AS

= ART RS
= A∗S∗,

(14.79)

and Cov(S∗) = R Cov(S) RT = I. Hence there are many such decom-
positions, and it is therefore impossible to identify any particular latent
variables as unique underlying sources. The SVD decomposition does have
the property that any rank q < p truncated decomposition approximates
X in an optimal way.

The classical factor analysis model, developed primarily by researchers in
psychometrics, alleviates these problems to some extent; see, for example,
Mardia et al. (1979). With q < p, a factor analysis model has the form

X1 = a11S1 +
X2 = a21S1 +

...

...

Xp = ap1S1 +

+ a1qSq + ε1
+ a2qSq + ε2

+ apqSq + εp,

· · ·
· · ·

· · ·

(14.80)

×

or X = AS + ε. Here S is a vector of q < p underlying latent variables or
factors, A is a p
q matrix of factor loadings, and the εj are uncorrelated
zero-mean disturbances. The idea is that the latent variables Sℓ are com-
mon sources of variation amongst the Xj, and account for their correlation
structure, while the uncorrelated εj are unique to each Xj and pick up the
remaining unaccounted variation. Typically the Sℓ and the εj are modeled
as Gaussian random variables, and the model is ﬁt by maximum likelihood.
The parameters all reside in the covariance matrix

Σ = AAT + Dε,

(14.81)

where Dε = diag[Var(ε1), . . . , Var(εp)]. The Sℓ being Gaussian and un-
correlated makes them statistically independent random variables. Thus a
battery of educational test scores would be thought to be driven by the
independent underlying factors such as intelligence, drive and so on. The
columns of A are referred to as the factor loadings, and are used to name
and interpret the factors.

560

14. Unsupervised Learning

×

Unfortunately the identiﬁability issue (14.79) remains, since A and ART
q orthogonal R. This leaves a certain
are equivalent in (14.81) for any q
subjectivity in the use of factor analysis, since the user can search for ro-
tated versions of the factors that are more easily interpretable. This aspect
has left many analysts skeptical of factor analysis, and may account for its
lack of popularity in contemporary statistics. Although we will not go into
details here, the SVD plays a key role in the estimation of (14.81). For ex-
ample, if the Var(εj) are all assumed to be equal, the leading q components
of the SVD identify the subspace determined by A.

Because of the separate disturbances εj for each Xj, factor analysis can
be seen to be modeling the correlation structure of the Xj rather than the
covariance structure. This can be easily seen by standardizing the covari-
ance structure in (14.81) (Exercise 14.14). This is an important distinction
between factor analysis and PCA, although not central to the discussion
here. Exercise 14.15 discusses a simple example where the solutions from
factor analysis and PCA diﬀer dramatically because of this distinction.

14.7.2 Independent Component Analysis

The independent component analysis (ICA) model has exactly the same
form as (14.78), except the Sℓ are assumed to be statistically indepen-
dent rather than uncorrelated. Intuitively, lack of correlation determines
the second-degree cross-moments (covariances) of a multivariate distribu-
tion, while in general statistical independence determines all of the cross-
moments. These extra moment conditions allow us to identify the elements
of A uniquely. Since the multivariate Gaussian distribution is determined
by its second moments alone, it is the exception, and any Gaussian inde-
pendent components can be determined only up to a rotation, as before.
Hence identiﬁability problems in (14.78) and (14.80) can be avoided if we
assume that the Sℓ are independent and non-Gaussian.

Here we will discuss the full p-component model as in (14.78), where the
Sℓ are independent with unit variance; ICA versions of the factor analysis
model (14.80) exist as well. Our treatment is based on the survey article
by Hyv¨arinen and Oja (2000).

We wish to recover the mixing matrix A in X = AS. Without loss
of generality, we can assume that X has already been whitened to have
Cov(X) = I; this is typically achieved via the SVD described above. This
in turn implies that A is orthogonal, since S also has covariance I. So
solving the ICA problem amounts to ﬁnding an orthogonal A such that
the components of the vector random variable S = AT X are independent
(and non-Gaussian).

Figure 14.37 shows the power of ICA in separating two mixed signals.
This is an example of the classical cocktail party problem, where diﬀer-
ent microphones Xj pick up mixtures of diﬀerent independent sources Sℓ
(music, speech from diﬀerent speakers, etc.). ICA is able to perform blind

14.7 Independent Component Analysis and Exploratory Projection Pursuit

561

Source Signals

Measured Signals

PCA Solution

ICA Solution

FIGURE 14.37. Illustration of ICA vs. PCA on artiﬁcial time-series data. The
upper left panel shows the two source signals, measured at 1000 uniformly spaced
time points. The upper right panel shows the observed mixed signals. The lower
two panels show the principal components and independent component solutions.

source separation, by exploiting the independence and non-Gaussianity of
the original sources.

Many of the popular approaches to ICA are based on entropy. The dif-

ferential entropy H of a random variable Y with density g(y) is given by

H(Y ) =

−

Z

g(y) log g(y)dy.

(14.82)

A well-known result in information theory says that among all random
variables with equal variance, Gaussian variables have the maximum en-
tropy. Finally, the mutual information I(Y ) between the components of the
random vector Y is a natural measure of dependence:

p

I(Y ) =

H(Yj)

j=1
X

H(Y ).

−

(14.83)

The quantity I(Y ) is called the Kullback–Leibler distance between the
p
density g(y) of Y and its independence version
j=1 gj(yj), where gj(yj)
is the marginal density of Yj. Now if X has covariance I, and Y = AT X
with A orthogonal, then it is easy to show that

Q

p

I(Y ) =

H(Yj)

=

j=1
X
p

j=1
X

H(Yj)

−

−

H(X)

log

|

−

det A

|

H(X).

(14.84)

(14.85)

Finding an A to minimize I(Y ) = I(AT X) looks for the orthogonal trans-
formation that leads to the most independence between its components. In

562

14. Unsupervised Learning

Source S

Data X

*

*

*

*

*

*

*
*
*

*
*

*
*
*
*

*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
***
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
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*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
* * *
*
*
*
* *
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
* *
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*

*
*
*
*
*

*
*
*

*
*

*
*

*

FIGURE 14.38. Mixtures of independent uniform random variables. The upper
left panel shows 500 realizations from the two independent uniform sources, the
upper right panel their mixed versions. The lower two panels show the PCA and
ICA solutions, respectively.

light of (14.84) this is equivalent to minimizing the sum of the entropies of
the separate components of Y , which in turn amounts to maximizing their
departures from Gaussianity.

For convenience, rather than using the entropy H(Yj), Hyv¨arinen and

Oja (2000) use the negentropy measure J(Yj) deﬁned by

J(Yj) = H(Zj)

H(Yj),

−

(14.86)

where Zj is a Gaussian random variable with the same variance as Yj. Ne-
gentropy is non-negative, and measures the departure of Yj from Gaussian-
ity. They propose simple approximations to negentropy which can be com-
puted and optimized on data. The ICA solutions shown in Figures 14.37–
14.39 use the approximation

J(Yj)

≈

[EG(Yj)

−
a

EG(Zj)]2,

(14.87)

a log cosh(au) for 1

where G(u) = 1
2. When applied to a sample
≤
of xi, the expectations are replaced by data averages. This is one of the
options in the FastICA software provided by these authors. More classical
(and less robust) measures are based on fourth moments, and hence look for
departures from the Gaussian via kurtosis. See Hyv¨arinen and Oja (2000)
for more details. In Section 14.7.4 we describe their approximate Newton
algorithm for ﬁnding the optimal directions.

≤

In summary then, ICA applied to multivariate data looks for a sequence
of orthogonal projections such that the projected data look as far from

14.7 Independent Component Analysis and Exploratory Projection Pursuit

563

ICA Components

s
t
n
e
n
o
p
m
o
C
A
C
P

Component
 1

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
oo
o o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o o
o
o
o
o
oo
o
o
o
o
o
o
o
o
oo
o
o
oo
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
oo
oo
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
oo
o
oo
o
o
oo
o
o
o
o o
o
o
o
oo
o
o
o
o
o
o
o
oo
o
o
o
oo
o
o
o
o
o
o
oo
o
o
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
o
o
oo
o
o
o
o
oo
oo
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
ooo
o o
o
oo
o
o
o
oo
o
o
o
o
o
o
o
oo
o
oo
o
o
o
o
o
o
o
o
oo
o
o
oo
o
o
o
o
o
oo
o
o
o
o o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
oo o
o
oo
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o o
o
o
o
o
o
o
o
o
o o
o o
o
o
o
o
o
oo
o
o
o
oo
o
o
o
o
o
o
o
o
o
ooo
o
o
o
o
o
o
o
o
o
o o
o
o
oo
o
o
o
ooo
o
o
o
o
o
o
o
o
o
o
ooo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
oo
o
oo
o
oo
o
o
o
oo o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

FIGURE 14.39. A comparison of the ﬁrst ﬁve ICA components computed using
FastICA (above diagonal) with the ﬁrst ﬁve PCA components(below diagonal).
Each component is standardized to have unit variance.

Gaussian as possible. With pre-whitened data, this amounts to looking for
components that are as independent as possible.

ICA starts from essentially a factor analysis solution, and looks for rota-
tions that lead to independent components. From this point of view, ICA is
just another factor rotation method, along with the traditional “varimax”
and “quartimax” methods used in psychometrics.

Example: Handwritten Digits

We revisit the handwritten threes analyzed by PCA in Section 14.5.1. Fig-
ure 14.39 compares the ﬁrst ﬁve (standardized) principal components with
the ﬁrst ﬁve ICA components, all shown in the same standardized units.
Note that each plot is a two-dimensional projection from a 256-dimensional

 
564

14. Unsupervised Learning

Mean

ICA 1

ICA 2

ICA 3

ICA 4

ICA 5

FIGURE 14.40. The highlighted digits from Figure 14.39. By comparing with
the mean digits, we see the nature of the ICA component.

space. While the PCA components all appear to have joint Gaussian distri-
butions, the ICA components have long-tailed distributions. This is not too
surprising, since PCA focuses on variance, while ICA speciﬁcally looks for
non-Gaussian distributions. All the components have been standardized,
so we do not see the decreasing variances of the principal components.

For each ICA component we have highlighted two of the extreme digits,
as well as a pair of central digits and displayed them in Figure 14.40.
This illustrates the nature of each of the components. For example, ICA
component ﬁve picks up the long sweeping tailed threes.

Example: EEG Time Courses

ICA has become an important tool in the study of brain dynamics—the
example we present here uses ICA to untangle the components of signals
in multi-channel electroencephalographic (EEG) data (Onton and Makeig,
2006).

Subjects wear a cap embedded with a lattice of 100 EEG electrodes,
which record brain activity at diﬀerent locations on the scalp. Figure 14.4111
(top panel) shows 15 seconds of output from a subset of nine of these elec-
trodes from a subject performing a standard “two-back” learning task over
a 30 minute period. The subject is presented with a letter (B, H, J, C, F, or
K) at roughly 1500-ms intervals, and responds by pressing one of two but-
tons to indicate whether the letter presented is the same or diﬀerent from
that presented two steps back. Depending on the answer, the subject earns
or loses points, and occasionally earns bonus or loses penalty points. The
time-course data show spatial correlation in the EEG signals—the signals
of nearby sensors look very similar.

The key assumption here is that signals recorded at each scalp electrode
are a mixture of independent potentials arising from diﬀerent cortical ac-

11Reprinted from Progress in Brain Research, Vol. 159, Julie Onton and Scott Makeig,
“Information based modeling of event-related brain dynamics,” Page 106 , Copyright
(2006), with permission from Elsevier. We thank Julie Onton and Scott Makeig for
supplying an electronic version of the image.

14.7 Independent Component Analysis and Exploratory Projection Pursuit

565

tivities, as well as non-cortical artifact domains; see the reference for a
detailed overview of ICA in this domain.

The lower part of Figure 14.41 shows a selection of ICA components.
The colored images represent the estimated unmixing coeﬃcient vectors ˆaj
as heatmap images superimposed on the scalp, indicating the location of
activity. The corresponding time-courses show the activity of the learned
ICA components.

For example, the subject blinked after each performance feedback signal
(colored vertical lines), which accounts for the location and artifact signal
in IC1 and IC3. IC12 is an artifact associated with the cardiac pulse. IC4
and IC7 account for frontal theta-band activities, and appear after a stretch
of correct performance. See Onton and Makeig (2006) for a more detailed
discussion of this example, and the use of ICA in EEG modeling.

14.7.3 Exploratory Projection Pursuit

Friedman and Tukey (1974) proposed exploratory projection pursuit, a
graphical exploration technique for visualizing high-dimensional data. Their
view was that most low (one- or two-dimensional) projections of high-
dimensional data look Gaussian. Interesting structure, such as clusters or
long tails, would be revealed by non-Gaussian projections. They proposed
a number of projection indices for optimization, each focusing on a diﬀer-
ent departure from Gaussianity. Since their initial proposal, a variety of
improvements have been suggested (Huber, 1985; Friedman, 1987), and a
variety of indices, including entropy, are implemented in the interactive
graphics package Xgobi (Swayne et al., 1991, now called GGobi). These
projection indices are exactly of the same form as J(Yj) above, where
Yj = aT
j X, a normalized linear combination of the components of X. In
fact, some of the approximations and substitutions for cross-entropy coin-
cide with indices proposed for projection pursuit. Typically with projection
pursuit, the directions aj are not constrained to be orthogonal. Friedman
(1987) transforms the data to look Gaussian in the chosen projection, and
then searches for subsequent directions. Despite their diﬀerent origins, ICA
and exploratory projection pursuit are quite similar, at least in the repre-
sentation described here.

14.7.4 A Direct Approach to ICA

Independent components have by deﬁnition a joint product density

p

fS(s) =

fj(sj),

(14.88)

j=1
Y
so here we present an approach that estimates this density directly us-
ing generalized additive models (Section 9.1). Full details can be found in

566

14. Unsupervised Learning

FIGURE 14.41. Fifteen seconds of EEG data (of 1917 seconds) at nine (of
100) scalp channels (top panel), as well as nine ICA components (lower panel).
While nearby electrodes record nearly identical mixtures of brain and non-brain
activity, ICA components are temporally distinct. The colored scalps represent the
ICA unmixing coeﬃcients ˆaj as a heatmap, showing brain or scalp location of the
source.

14.7 Independent Component Analysis and Exploratory Projection Pursuit

567

Hastie and Tibshirani (2003), and the method is implemented in the R
package ProDenICA, available from CRAN.

In the spirit of representing departures from Gaussianity, we represent

each fj as

fj(sj) = φ(sj)egj (sj ),
a tilted Gaussian density. Here φ is the standard Gaussian density, and
gj satisﬁes the normalization conditions required of a density. Assuming
as before that X is pre-whitened, the log-likelihood for the observed data
X = AS is

(14.89)

ℓ(A,

p
1; X) =

gj}
{

N

p

i=1
X

j=1
X

(cid:2)

log φj(aT

j xi) + gj(aT

j xi

],

(14.90)

(cid:1)

which we wish to maximize subject to the constraints that A is orthogonal
and that the gj result in densities in (14.89). Without imposing any further
restrictions on gj, the model (14.90) is over-parametrized, so we instead
maximize a regularized version

p

N

1
N

log φ(aT

j xi) + gj(aT

j xi)

φ(t)egj (t)dt

λj

−

g′′′
j (t)
{

2(t)dt
}

.

−

(cid:2)

i=1
X

j=1 "
X

#
(14.91)
We have subtracted two penalty terms (for each j) in (14.91), inspired by
Silverman (1986, Section 5.4.4):

Z

Z

(cid:3)

•

The ﬁrst enforces the density constraint
solution ˆgj.

R

φ(t)eˆgj (t)dt = 1 on any

•

The second is a roughness penalty, which guarantees that the solution
ˆgj is a quartic-spline with knots at the observed values of sij = aT
j xi.
It can further be shown that the solution densities ˆfj = φeˆgj each have
mean zero and variance one (Exercise 14.18). As we increase λj, these
solutions approach the standard Gaussian φ.

Algorithm 14.3 Product Density ICA Algorithm: ProDenICA

1. Initialize A (random Gaussian matrix followed by orthogonalization).

2. Alternate until convergence of A:

(a) Given A, optimize (14.91) w.r.t. gj (separately for each j).
(b) Given gj, j = 1, . . . , p, perform one step of a ﬁxed point algo-

rithm towards ﬁnding the optimal A.

We ﬁt the functions gj and directions aj by optimizing (14.91) in an

alternating fashion, as described in Algorithm 14.3.

568

14. Unsupervised Learning

Step 2(a) amounts to a semi-parametric density estimation, which can
be solved using a novel application of generalized additive models. For
convenience we extract one of the p separate problems,

1
N

N

i=1
X

[log φ(si) + g(si)]

φ(t)eg(t)dt

λ

−

Z

g′′′(t)
{

2(t)dt.
}

−

Z

(14.92)

Although the second integral in (14.92) leads to a smoothing spline, the
ﬁrst integral is problematic, and requires an approximation. We construct
a ﬁne grid of L values s∗
ℓ in increments ∆ covering the observed values si,
and count the number of si in the resulting bins:

y∗
ℓ =

#si ∈

(s∗

ℓ −

ℓ + ∆/2)

∆/2, s∗
N

.

(14.93)

Typically we pick L to be 1000, which is more than adequate. We can then
approximate (14.92) by

L

Xℓ=1 n

y∗
i [log(φ(s∗

ℓ )) + g(s∗

ℓ )]

∆φ(s∗

ℓ )eg(s∗
ℓ )

−

λ

−

Z

o

g′′′2(s)ds.

(14.94)

This last expression can be seen to be proportional to a penalized Poisson
log-likelihood with response y∗
ℓ /∆ and penalty parameter λ/∆, and mean
µ(s) = φ(s)eg(s). This is a generalized additive spline model (Hastie and
Tibshirani, 1990; Efron and Tibshirani, 1996), with an oﬀset term log φ(s),
and can be ﬁt using a Newton algorithm in O(L) operations. Although
a quartic spline is called for, we ﬁnd in practice that a cubic spline is
adequate. We have p tuning parameters λj to set; in practice we make
them all the same, and specify the amount of smoothing via the eﬀective
degrees-of-freedom df(λ). Our software uses 5df as a default value.

Step 2(b) in Algorithm 14.3 requires optimizing (14.92) with respect to
A, holding the ˆgj ﬁxed. Only the ﬁrst terms in the sum involve A, and
since A is orthogonal, the collection of terms involving φ do not depend on
A (Exercise 14.19). Hence we need to maximize

ˆgj(aT

j xi)

(14.95)

C(A) =

=

1
N

p

p

N

j=1
X

i=1
X

Cj(aj)

j=1
X

C(A) is a log-likelihood ratio between the ﬁtted density and a Gaussian,
and can be seen as an estimate of negentropy (14.86), with each ˆgj a con-
trast function as in (14.87). The ﬁxed point update in step 2(b) is a modiﬁed
Newton step (Exercise 14.20)

14.7 Independent Component Analysis and Exploratory Projection Pursuit

569

1. For each j update

aj ←

E

X ˆg′

j(aT

j X)

E[ˆg′′

j (aT

j X)]aj

,

(14.96)

−

where E represents expectation w.r.t the sample xi. Since ˆgj is a ﬁtted
quartic (or cubic) spline, the ﬁrst and second derivatives are readily
available.

(cid:9)

(cid:8)

2. Orthogonalize A using the symmetric square-root transformation

2 A. If A = UDVT is the SVD of A, it is easy to show that

(AAT )− 1
this leads to the update A

UVT .

←

Our ProDenICA algorithm works as well as FastICA on the artiﬁcial time
series data of Figure 14.37, the mixture of uniforms data of Figure 14.38,
and the digit data in Figure 14.39.

FastICA
KernelICA
ProdDenICA

Example: Simulations

a

d

g

j

m

p

b

e

h

k

n

q

c

f

i

l

o

r

A
e
u
r
T
m
o
r
f

e
c
n
a
t
s
D

i

i
r
a
m
A

0
5
.
0

0
2
.
0

0
1
.
0

5
0
.
0

2
0
.
0

1
0
.
0

a

b

c

d

e

f

g

h

i

j

k

l m n

o

p

q

r

Distribution

FIGURE 14.42. The left panel shows 18 distributions used for comparisons.
These include the “t”, uniform, exponential, mixtures of exponentials, symmetric
and asymmetric Gaussian mixtures. The right panel shows (on the log scale)
the average Amari metric for each method and each distribution, based on 30
simulations in IR2 for each distribution.

Figure 14.42 shows the results of a simulation comparing ProDenICA to
FastICA, and another semi-parametric competitor KernelICA (Bach and
Jordan, 2002). The left panel shows the 18 distributions used as a basis
of comparison. For each distribution, we generated a pair of independent
components (N = 1024), and a random mixing matrix in IR2 with condition
number between 1 and 2. We used our R implementations of FastICA, using
the negentropy criterion (14.87), and ProDenICA. For KernelICA we used

 
 
 
 
570

14. Unsupervised Learning

the authors MATLAB code.12 Since the search criteria are nonconvex, we
used ﬁve random starts for each method. Each of the algorithms delivers
an orthogonal mixing matrix A (the data were pre-whitened), which is
available for comparison with the generating orthogonalized mixing matrix
A0. We used the Amari metric (Bach and Jordan, 2002) as a measure of
the closeness of the two frames:

p

d(A0, A) =

1
2p

p
j=1 |
maxj |

rij|
rij|

+

1
!

−

1
2p

p

p
i=1 |
maxi |

rij|
rij|

j=1 (cid:18) P
X

i=1   P
X

, (14.97)

−

1
(cid:19)

where rij = (AoA−1)ij. The right panel in Figure 14.42 compares the
averages (on the log scale) of the Amari metric between the truth and the
estimated mixing matrices. ProDenICA is competitive with FastICA and
KernelICA in all situations, and dominates most of the mixture simulations.

14.8 Multidimensional Scaling

Both self-organizing maps and principal curves and surfaces map data
points in IRp to a lower-dimensional manifold. Multidimensional scaling
(MDS) has a similar goal, but approaches the problem in a somewhat dif-
ferent way.

||

xj||

xi −

We start with observations x1, x2, . . . , xN ∈

IRp, and let dij be the dis-
tance between observations i and j. Often we choose Euclidean distance
dij =
, but other distances may be used. Further, in some ap-
plications we may not even have available the data points xi, but only
have some dissimilarity measure dij (see Section 14.3.10). For example, in
a wine tasting experiment, dij might be a measure of how diﬀerent a sub-
ject judged wines i and j, and the subject provides such a measure for all
pairs of wines i, j. MDS requires only the dissimilarities dij, in contrast to
the SOM and principal curves and surfaces which need the data points xi.
IRk to minimize

Multidimensional scaling seeks values z1, z2, . . . , zN ∈

the so-called stress function13

SM (z1, z2, . . . , zN ) =

(dii′

zi −

zi′

||

− ||

)2.

(14.98)

Xi6=i′
This is known as least squares or Kruskal–Shephard scaling. The idea is
to ﬁnd a lower-dimensional representation of the data that preserves the
pairwise distances as well as possible. Notice that the approximation is

12Francis Bach kindly supplied this code, and helped us set up the simulations.
13Some authors deﬁne stress as the square-root of SM ; since it does not aﬀect the

optimization, we leave it squared to make comparisons with other criteria simpler.

14.8 Multidimensional Scaling

571

in terms of the distances rather than squared distances (which results in
slightly messier algebra). A gradient descent algorithm is used to minimize
SM .

A variation on least squares scaling is the so-called Sammon mapping

which minimizes

SSm(z1, z2, . . . , zN ) =

(dii′

− ||

zi −
dii′

zi′

)2

||

.

Xi6=i′

(14.99)

Here more emphasis is put on preserving smaller pairwise distances.

In classical scaling, we instead start with similarities sii′ : often we use
xi −
. The problem then is to

the centered inner product sii′ =
minimize

¯x, xi′

−

¯x

h

i

SC(z1, z2, . . . , zN ) =

Xi,i′

(sii′

zi −

− h

¯z, zi′

)2

¯z
i

−

(14.100)

IRk. This is attractive because there is an explicit
over z1, z2, . . . , zN ∈
solution in terms of eigenvectors: see Exercise 14.11. If we have distances
rather than inner-products, we can convert them to centered inner-products
if the distances are Euclidean;14 see (18.31) on page 671 in Chapter 18.
If the similarities are in fact centered inner-products, classical scaling is
exactly equivalent to principal components, an inherently linear dimension-
reduction technique. Classical scaling is not equivalent to least squares
scaling; the loss functions are diﬀerent, and the mapping can be nonlinear.
Least squares and classical scaling are referred to as metric scaling meth-
ods, in the sense that the actual dissimilarities or similarities are approx-
imated. Shephard–Kruskal nonmetric scaling eﬀectively uses only ranks.
Nonmetric scaling seeks to minimize the stress function

SNM(z1, z2, . . . , zN ) =

i6=i′

P

(cid:2)

zi −
||

||
i6=i′

zi′
|| −
zi′
zi −

||

θ(dii′ )
2

2

(cid:3)

(14.101)

zi′

P
over the zi and an arbitrary increasing function θ. With θ ﬁxed, we min-
imize over zi by gradient descent. With the zi ﬁxed, the method of iso-
tonic regression is used to ﬁnd the best monotonic approximation θ(dii′ )
to

. These steps are iterated until the solutions stabilize.
zi −
||
Like the self-organizing map and principal surfaces, multidimensional
scaling represents high-dimensional data in a low-dimensional coordinate
system. Principal surfaces and SOMs go a step further, and approximate
the original data by a low-dimensional manifold, parametrized in the low
dimensional coordinate system. In a principal surface and SOM, points

||

14An N × N distance matrix is Euclidean if the entries represent pairwise Euclidean

distances between N points in some dimensional space.

572

14. Unsupervised Learning

i

e
t
a
n
d
r
o
o
C
S
D
M
d
n
o
c
e
S

0
.
1

5
.
0

0
.
0

5
.
0
-

.

0
1
-

•
•
• •
•
•
•
•

•
•

•
•
•

•

•

•
•
•

•

•

•

•

•

•

•
•
•

•

•

•

•

•

•

•

•

•

•

•

•

•
•

•

•
•
•
• •
•
•
•
•

•

•

•
•
•

•
•
•
••
•
•
•
•
•• •
•
•
•
•
•
•
•
•
•
•
•
•
•
•

•
•

•

•

0.0

-1.0

-0.5

•
•
• •

0.5

1.0

First MDS Coordinate

FIGURE 14.43. First two coordinates for half-sphere data, from classical multi-
dimensional scaling.

close together in the original feature space should map close together on
the manifold, but points far apart in feature space might also map close
together. This is less likely in multidimensional scaling since it explicitly
tries to preserve all pairwise distances.

Figure 14.43 shows the ﬁrst two MDS coordinates from classical scaling
for the half-sphere example. There is clear separation of the clusters, and
the tighter nature of the red cluster is apparent.

14.9 Nonlinear Dimension Reduction and Local

Multidimensional Scaling

Several methods have been recently proposed for nonlinear dimension re-
duction, similar in spirit to principal surfaces. The idea is that the data lie
close to an intrinsically low-dimensional nonlinear manifold embedded in a
high-dimensional space. These methods can be thought of as “ﬂattening”
the manifold, and hence reducing the data to a set of low-dimensional co-
ordinates that represent their relative positions in the manifold. They are
useful for problems where signal-to-noise ratio is very high (e.g., physical
systems), and are probably not as useful for observational data with lower
signal-to-noise ratios.

The basic goal is illustrated in the left panel of Figure 14.44. The data
lie near a parabola with substantial curvature. Classical MDS does not pre-

 
 
14.9 Nonlinear Dimension Reduction and Local Multidimensional Scaling

573

Classical MDS

Local MDS

2
x

0

5
−

0
1
−

5
1
−

2
x

0

5
−

0
1
−

5
1
−

−5

0

x1

5

−5

5

0

x1

FIGURE 14.44. The orange points show data lying on a parabola, while the blue
points shows multidimensional scaling representations in one dimension. Classical
multidimensional scaling (left panel) does not preserve the ordering of the points
along the curve, because it judges points on opposite ends of the curve to be close
together. In contrast, local multidimensional scaling (right panel) does a good job
of preserving the ordering of the points along the curve.

serve the ordering of the points along the curve, because it judges points
on opposite ends of the curve to be close together. The right panel shows
the results of local multi-dimensional scaling, one of the three methods for
non-linear multi-dimensional scaling that we discuss below. These meth-
ods use only the coordinates of the points in p dimensions, and have no
other information about the manifold. Local MDS has done a good job of
preserving the ordering of the points along the curve.

We now brieﬂy describe three new approaches to nonlinear dimension

reduction and manifold mapping.

Isometric feature mapping (ISOMAP) (Tenenbaum et al., 2000) con-
structs a graph to approximate the geodesic distance between points along
the manifold. Speciﬁcally, for each data point we ﬁnd its neighbors—points
within some small Euclidean distance of that point. We construct a graph
with an edge between any two neighboring points. The geodesic distance
between any two points is then approximated by the shortest path be-
tween points on the graph. Finally, classical scaling is applied to the graph
distances, to produce a low-dimensional mapping.

Local linear embedding (Roweis and Saul, 2000) takes a very diﬀerent ap-
proach, trying to preserve the local aﬃne structure of the high-dimensional
data. Each data point is approximated by a linear combination of neigh-
boring points. Then a lower dimensional representation is constructed that

574

14. Unsupervised Learning

best preserves these local approximations. The details are interesting, so
we give them here.

1. For each data point xi in p dimensions, we ﬁnd its K-nearest neigh-

bors

N

(i) in Euclidean distance.

2. We approximate each point by an aﬃne mixture of the points in its

neighborhood:

min
Wik ||

xi −

2

wikxk||

Xk∈N (i)

(14.102)

N
over weights wik satisfying wik = 0, k /
k=1 wik = 1. wik
is the contribution of point k to the reconstruction of point i. Note
that for a hope of a unique solution, we must have K < p.

∈ N

(i),

P

3. Finally, we ﬁnd points yi in a space of dimension d < p to minimize

N

N

yi −

||

i=1
X

Xk=1

2

wikyk||

(14.103)

with wik ﬁxed.

In step 3, we minimize

tr[(Y

WY)T (Y

WY)] = tr[YT (I

W)T (I

W)Y]

−

−

−

N ; Y is N

−
d, for some small d < p. The solutions ˆY
where W is N
W). Since 1 is a trivial
are the trailing eigenvectors of M = (I
eigenvector with eigenvalue 0, we discard it and keep the next d. This has
the side eﬀect that 1T Y = 0, and hence the embedding coordinates are
mean centered.

W)T (I

×

×

−

−

(14.104)

Local MDS (Chen and Buja, 2008) takes the simplest and arguably the
to be the symmetric set of nearby pairs
if point i is among the K-nearest

most direct approach. We deﬁne
N
of points; speciﬁcally a pair (i, i′) is in
neighbors of i′, or vice-versa. Then we construct the stress function

N

SL(z1, z2, . . . , zN ) =

X(i,i′)∈N
+

(dii′

zi −

zi′

||

− ||

)2

(D

w

·

zi −

zi′

||

− ||

)2. (14.105)

X(i,i′) /∈N

Here D is some large constant and w is a weight. The idea is that points
that are not neighbors are considered to be very far apart; such pairs are
given a small weight w so that they don’t dominate the overall stress func-
.
tion. To simplify the expression, we take w
Expanding (14.105), this gives

1/D, and let D

→ ∞

∼

14.9 Nonlinear Dimension Reduction and Local Multidimensional Scaling

575

FIGURE 14.45. Images of faces mapped into the embedding space described by
the ﬁrst two coordinates of LLE. Next to the circled points, representative faces
are shown in diﬀerent parts of the space. The images at the bottom of the plot
correspond to points along the top right path (linked by solid line), and illustrate
one particular mode of variability in pose and expression.

576

14. Unsupervised Learning

SL(z1, z2, . . . , zN ) =

(dii′

zi −

zi′

||

− ||

)2

τ

−

zi −

||

zi′

,

||

X(i,i′)∈N

X(i,i′) /∈N

(14.106)
where τ = 2wD. The ﬁrst term in (14.106) tries to preserve local structure
in the data, while the second term encourages the representations zi, zi′
for pairs (i, i′) that are non-neighbors to be farther apart. Local MDS
minimizes the stress function (14.106) over zi, for ﬁxed values of the number
of neighbors K and the tuning parameter τ .

The right panel of Figure 14.44 shows the result of local MDS, using k = 2
neighbors and τ = 0.01. We used coordinate descent with multiple starting
values to ﬁnd a good minimum of the (nonconvex) stress function (14.106).
The ordering of the points along the curve has been largely preserved,

Figure 14.45 shows a more interesting application of one of these meth-
ods (LLE)15. The data consist of 1965 photographs, digitized as 20
28
grayscale images. The result of the ﬁrst two-coordinates of LLE are shown
and reveal some variability in pose and expression. Similar pictures were
produced by local MDS.

×

In experiments reported in Chen and Buja (2008), local MDS shows su-
perior performance, as compared to ISOMAP and LLE. They also demon-
strate the usefulness of local MDS for graph layout. There are also close
connections between the methods discussed here, spectral clustering (Sec-
tion 14.5.3) and kernel PCA (Section 14.5.4).

14.10 The Google PageRank Algorithm

In this section we give a brief description of the original PageRank algo-
rithm used by the Google search engine, an interesting recent application
of unsupervised learning methods.

We suppose that we have N web pages and wish to rank them in terms
of importance. For example, the N pages might all contain a string match
to “statistical learning” and we might wish to rank the pages in terms of
their likely relevance to a websurfer.

The PageRank algorithm considers a webpage to be important if many
other webpages point to it. However the linking webpages that point to a
given page are not treated equally: the algorithm also takes into account
both the importance (PageRank ) of the linking pages and the number of
outgoing links that they have. Linking pages with higher PageRank are
given more weight, while pages with more outgoing links are given less
weight. These ideas lead to a recursive deﬁnition for PageRank, detailed
next.

15Sam Roweis and Lawrence Saul kindly provided this ﬁgure.

14.10 The Google PageRank Algorithm

577

Let Lij = 1 if page j points to page i, and zero otherwise. Let cj =
N
i=1 Lij equal the number of pages pointed to by page j (number of out-
links). Then the Google PageRanks pi are deﬁned by the recursive rela-
P
tionship

pi = (1

d) + d

−

N

j=1
X

(cid:0)

(cid:1)

Lij
cj

pj

(14.107)

where d is a positive constant (apparently set to 0.85).

The idea is that the importance of page i is the sum of the importances of
pages that point to that page. The sums are weighted by 1/cj, that is, each
page distributes a total vote of 1 to other pages. The constant d ensures
that each page gets a PageRank of at least 1

d. In matrix notation

p = (1

d)e + d

·

−

−
LD−1
c p

(14.108)

where e is a vector of N ones and Dc = diag(c) is a diagonal matrix with
diagonal elements cj. Introducing the normalization eT p = N (i.e., the
average PageRank is 1), we can write (14.108) as

p =

(1
= Ap
(cid:2)
where the matrix A is the expression in square braces.

d)eeT /N + dLD−1

−

p

(cid:3)

c

(14.109)

Exploiting a connection with Markov chains (see below), it can be shown
that the matrix A has a real eigenvalue equal to one, and one is its largest
eigenvalue. This means that we can ﬁnd ˆp by the power method: starting
with some p = p0 we iterate

pk ←

Apk−1; pk ←

N

pk
eT pk

.

(14.110)

The ﬁxed points ˆp are the desired PageRanks.

In the original paper of Page et al. (1998), the authors considered PageR-
ank as a model of user behavior, where a random web surfer clicks on links
at random, without regard to content. The surfer does a random walk on
the web, choosing among available outgoing links at random. The factor
1
d is the probability that he does not click on a link, but jumps instead
to a random webpage.

−

−

Some descriptions of PageRank have (1

d)/N as the ﬁrst term in def-
inition (14.107), which would better coincide with the random surfer in-
terpretation. Then the page rank solution (divided by N ) is the stationary
distribution of an irreducible, aperiodic Markov chain over the N webpages.
Deﬁnition (14.107) also corresponds to an irreducible, aperiodic Markov
chain, with diﬀerent transition probabilities than those from he (1
d)/N
version. Viewing PageRank as a Markov chain makes clear why the matrix
A has a maximal real eigenvalue of 1. Since A has positive entries with

−

578

14. Unsupervised Learning

Page 1

Page 2

Page 4

Page 3

FIGURE 14.46. PageRank algorithm: example of a small network

each column summing to one, Markov chain theory tells us that it has a
unique eigenvector with eigenvalue one, corresponding to the stationary
distribution of the chain (Bremaud, 1999).

A small network is shown for illustration in Figure 14.46. The link matrix

is

0
0

1
0



and the number of outlinks is c = (2, 1, 1, 1).

0
1
L = 
1
0




0 1
0 0
1 0
0 0

(14.111)

The PageRank solution is ˆp = (1.49, 0.78, 1.58, 0.15). Notice that page 4

has no incoming links, and hence gets the minimum PageRank of 0.15.

Bibliographic Notes

There are many books on clustering, including Hartigan (1975), Gordon
(1999) and Kaufman and Rousseeuw (1990). K-means clustering goes back
at least to Lloyd (1957), Forgy (1965), Jancey (1966) and MacQueen (1967).
Applications in engineering, especially in image compression via vector
quantization, can be found in Gersho and Gray (1992). The k-medoid pro-
cedure is described in Kaufman and Rousseeuw (1990). Association rules
are outlined in Agrawal et al. (1995). The self-organizing map was proposed
by Kohonen (1989) and Kohonen (1990); Kohonen et al. (2000) give a more
recent account. Principal components analysis and multidimensional scal-
ing are described in standard books on multivariate analysis, for example,
Mardia et al. (1979). Buja et al. (2008) have implemented a powerful en-
vironment called Ggvis for multidimensional scaling, and the user manual

Exercises

579

contains a lucid overview of the subject. Figures 14.17, 14.21 (left panel)
and 14.28 (left panel) were produced in Xgobi, a multidimensional data
visualization package by the same authors. GGobi is a more recent im-
plementation (Cook and Swayne, 2007). Goodall (1991) gives a technical
overview of Procrustes methods in statistics, and Ramsay and Silverman
(1997) discuss the shape registration problem. Principal curves and surfaces
were proposed in Hastie (1984) and Hastie and Stuetzle (1989). The idea of
principal points was formulated in Flury (1990), Tarpey and Flury (1996)
give an exposition of the general concept of self-consistency. An excellent
tutorial on spectral clustering can be found in von Luxburg (2007); this was
the main source for Section 14.5.3. Luxborg credits Donath and Hoﬀman
(1973) and Fiedler (1973) with the earliest work on the subject. A history
of spectral clustering my be found in Spielman and Teng (1996). Indepen-
dent component analysis was proposed by Comon (1994), with subsequent
developments by Bell and Sejnowski (1995); our treatment in Section 14.7
is based on Hyv¨arinen and Oja (2000). Projection pursuit was proposed by
Friedman and Tukey (1974), and is discussed in detail in Huber (1985). A
dynamic projection pursuit algorithm is implemented in GGobi.

Exercises

Ex. 14.1 Weights for clustering. Show that weighted Euclidean distance

satisﬁes

where

d(w)
e

(xi, xi′ ) =

p

l=1 wl(xil −
p
l=1 wl

P

xi′l)2

d(w)
e

(xi, xi′ ) = de(zi, zi′ ) =

P

p

(zil −

zi′l)2,

Xl=1

zil = xil ·

(cid:18)

1/2

.

wl
p
l=1 wl (cid:19)

(14.112)

(14.113)

Thus weighted Euclidean distance based on x is equivalent to unweighted
P
Euclidean distance based on z.

Ex. 14.2 Consider a mixture model density in p-dimensional feature space,

K

g(x) =

πkgk(x),

(14.114)

where gk = N (µk, L
·
1, . . . , K and σ2 are unknown parameters.

σ2) and πk ≥

k with

∀

Xk=1
0

k πk = 1. Here

µk, πk}
{

, k =

P

580

14. Unsupervised Learning

Suppose we have data x1, x2, . . . , xN ∼

ture model.

g(x) and we wish to ﬁt the mix-

1. Write down the log-likelihood of the data

2. Derive an EM algorithm for computing the maximum likelihood es-

timates (see Section 8.1).

3. Show that if σ has a known value in the mixture model and we take
0, then in a sense this EM algorithm coincides with K-means

σ
clustering.

→

Ex. 14.3 In Section 14.2.6 we discuss the use of CART or PRIM for con-
structing generalized association rules. Show that a problem occurs with ei-
ther of these methods when we generate the random data from the product-
marginal distribution; i.e., by randomly permuting the values for each of
the variables. Propose ways to overcome this problem.

Ex. 14.4 Cluster the demographic data of Table 14.1 using a classiﬁcation
tree. Speciﬁcally, generate a reference sample of the same size of the train-
ing set, by randomly permuting the values within each feature. Build a
classiﬁcation tree to the training sample (class 1) and the reference sample
(class 0) and describe the terminal nodes having highest estimated class 1
probability. Compare the results to the PRIM results near Table 14.1 and
also to the results of K-means clustering applied to the same data.

Ex. 14.5 Generate data with three features, with 30 data points in each of
three classes as follows:

−

π/8, π/8)

θ1 = U (
φ1 = U (0, 2π)
x1 = sin(θ1) cos(φ1) + W11
y1 = sin(θ1) sin(φ1) + W12
z1 = cos(θ1) + W13

π/4, π/2 + π/4)

−

π/4, π/4)

θ2 = U (π/2
φ2 = U (
x2 = sin(θ2) cos(φ2) + W21
y2 = sin(θ2) sin(φ2) + W22
z2 = cos(θ2) + W23

−

π/4, π/2 + π/4)
π/4, π/2 + π/4)

θ3 = U (π/2
φ3 = U (π/2
x3 = sin(θ3) cos(φ3) + W31
y3 = sin(θ3) sin(φ3) + W32
z3 = cos(θ3) + W33

−
−

Here U (a, b) indicates a uniform variate on the range [a, b] and Wjk are
independent normal variates with standard deviation 0.6. Hence the data

Exercises

581

lie near the surface of a sphere in three clusters centered at (1, 0, 0), (0, 1, 0)
and (0, 0, 1).

Write a program to ﬁt a SOM to these data, using the learning rates
given in the text. Carry out a K-means clustering of the same data, and
compare the results to those in the text.

Ex. 14.6 Write programs to implement K-means clustering and a self-
organizing map (SOM), with the prototype lying on a two-dimensional
grid. Apply them to the columns of the human tumor microarray data, us-
ing K = 2, 5, 10, 20 centroids for both. Demonstrate that as the size of the
SOM neighborhood is taken to be smaller and smaller, the SOM solution
becomes more similar to the K-means solution.

Ex. 14.7 Derive (14.51) and (14.52) in Section 14.5.1. Show that ˆµ is not
unique, and characterize the family of equivalent solutions.

Ex. 14.8 Derive the solution (14.57) to the Procrustes problem (14.56).
Derive also the solution to the Procrustes problem with scaling (14.58).

Ex. 14.9 Write an algorithm to solve

L

min
{βℓ,Rℓ}L

1 ,M

XℓRℓ −

||

M

2
F .

||

(14.115)

Xℓ=1

Apply it to the three S’s, and compare the results to those shown in Fig-
ure 14.26.

Ex. 14.10 Derive the solution to the aﬃne-invariant average problem (14.60).
Apply it to the three S’s, and compare the results to those computed in
Exercise 14.9.

Ex. 14.11 Classical multidimensional scaling. Let S be the centered in-
ner product matrix with elements
>
xi −
λk be the k largest eigenvalues of S, with associated eigenvectors Ek =
(e1, e2, . . . , ek). Let Dk be a diagonal matrix with diagonal entries √λ1,
√λ2, . . . , √λk. Show that the solutions zi to the classical scaling problem
(14.100) are the rows of EkDk.

. Let λ1 > λ2 >

¯x, xj −

· · ·

¯x

h

i

Ex. 14.12 Consider the sparse PCA criterion (14.71).

1. Show that with Θ ﬁxed, solving for V amounts to K separate elastic-
net regression problems, with responses the K elements of ΘT xi.

2. Show that with V ﬁxed, solving for Θ amounts to a reduced-rank

version of the Procrustes problem, which reduces to
trace(ΘT M) subject to ΘT Θ = IK,

max
Θ

(14.116)

where M and Θ are both p
SVD of M, show that the optimal Θ = UQT .

K with K

×

≤

p. If M = UDQT is the

582

14. Unsupervised Learning

Ex. 14.13 Generate 200 data points with three features, lying close to a
Z2, X3 =
helix. In detail, deﬁne X1 = cos(s) + 0.1
·
s + 0.1
Z3 where s takes on 200 equally spaced values between 0 and 2π,
and Z1, Z2, Z3 are independent and have standard Gaussian distributions.

Z1, X2 = sin(s) + 0.1

·

·

(a) Fit a principal curve to the data and plot the estimated coordinate
functions. Compare them to the underlying functions cos(s), sin(s)
and s.

(b) Fit a self-organizing map to the same data, and see if you can discover

the helical shape of the original point cloud.

Ex. 14.14 Pre- and post-multiply equation (14.81) by a diagonal matrix
containing the inverse variances of the Xj. Hence obtain an equivalent
decomposition for the correlation matrix, in the sense that a simple scaling
is applied to the matrix A.

Ex. 14.15 Generate 200 observations of three variates X1, X2, X3 according
to

Z1
X1 ∼
X2 = X1 + 0.001
X3 = 10

Z3

Z2

·

·
where Z1, Z2, Z3 are independent standard normal variates. Compute the
leading principal component and factor analysis directions. Hence show
that the leading principal component aligns itself in the maximal variance
direction X3, while the leading factor essentially ignores the uncorrelated
component X3, and picks up the correlated component X2 + X1 (Geoﬀrey
Hinton, personal communication).

(14.117)

Ex. 14.16 Consider the kernel principal component procedure outlined in
Section 14.5.4. Argue that the number M of principal components is equal
to the rank of K, which is the number of non-zero elements in D. Show
that the mth component zm (mth column of Z) can be written (up to
N
centering) as zim =
j=1 αjmK(xi, xj), where αjm = ujm/dm. Show that
the mapping of a new observation x0 to the mth component is given by
z0m =

N
j=1 αjmK(x0, xj).

P

P

N
j=1 cjK(x, xj), the solution to (14.66)
Ex. 14.17 Show that with g1(x) =
is given by ˆcj = uj1/d1, where u1 is the ﬁrst column of U in (14.65), and
d1 the ﬁrst diagonal element of D. Show that the second and subsequent
principal component functions are deﬁned in a similar manner (hint: see
Section 5.8.1.)

P

Ex. 14.18 Consider the regularized log-likelihood for the density estimation
problem arising in ICA,

1
N

N

i=1
X

[log φ(si) + g(si)]

φ(t)eg(t)dt

λ

−

Z

g′′′(t)
{

2(t)dt.
}

−

Z

(14.118)

Exercises

583

The solution ˆg is a quartic smoothing spline, and can be written as ˆg(s) =
ˆq(s) + ˆq⊥(s), where q is a quadratic function (in the null space of the
penalty). Let q(s) = θ0 + θ1s + θ2s2. By examining the stationarity condi-
tions for ˆθk, k = 1, 2, 3, show that the solution ˆf = φeˆg is a density, and
has mean zero and variance one. If we used a second-derivative penalty
2(t)dt instead, what simple modiﬁcation could we make to the
}

g′′(t)
{

problem to maintain the three moment conditions?
R
Ex. 14.19 If A is p
page 568

×

p orthogonal, show that the ﬁrst term in (14.92) on

p

N

j=1
X

i=1
X

log φ(aT

j xi),

with aj the jth column of A, does not depend on A.

Ex. 14.20 Fixed point algorithm for ICA (Hyv¨arinen et al., 2001). Consider
maximizing C(a) = E
= 1 and
Cov(X) = I. Use a Lagrange multiplier to enforce the norm constraint,
and write down the ﬁrst two derivatives of the modiﬁed criterion. Use the
approximation

with respect to a, with

g(aT X)
{

||

||

a

}

E

XX T g′′(aT X)
{

} ≈

E

XX T
{

E
}

g′′(aT X)
{

}

to show that the Newton update can be written as the ﬁxed-point update
(14.96).

Ex. 14.21 Consider an undirected graph with non-negative edge weights
wii′ and graph Laplacian L. Suppose there are m connected components
A1, A2, . . . , Am in the graph. Show that there are m eigenvectors of L corre-
sponding to eigenvalue zero, and the indicator vectors of these components
IA1, IA2 , . . . , IAm span the zero eigenspace.

Ex. 14.22

(a) Show that deﬁnition (14.108) implies that the sum of the PageRanks

pi is N , the number of web pages.

(b) Write a program to compute the PageRank solutions by the power
method using formulation (14.107). Apply it to the network of Fig-
ure 14.47.

Ex. 14.23 Algorithm for non-negative matrix factorization (Wu and Lange,
2007). A function g(x, y) to said to minorize a function f (x) if

584

14. Unsupervised Learning

Page 1

Page 4

Page 2

Page 6

Page 3

Page 5

FIGURE 14.47. Example of a small network.

g(x, y)

≤

f (x), g(x, x) = f (x)

(14.119)

for all x, y in the domain. This is useful for maximizing f (x) since it is easy
to show that f (x) is nondecreasing under the update

xs+1 = argmaxxg(x, xs)

(14.120)

There are analogous deﬁnitions for majorization, for minimizing a function
f (x). The resulting algorithms are known as MM algorithms, for “minorize-
It also can be shown
maximize” or “majorize-minimize” (Lange, 2004).
that the EM algorithm (8.5) is an example of an MM algorithm: see Sec-
tion 8.5.3 and Exercise 8.2 for details.

(a) Consider maximization of the function L(W, H) in (14.73), written

here without the matrix notation

L(W, H) =

N

p

xij log

j=1 "
X

i=1
X

r

Xk=1

wikhkj

r

! −

Xk=1

wikhkj

.

#

Using the concavity of log(x), show that for any set of r values yk ≥
and 0

1 with

0

ck ≤

≤

r
k=1 ck = 1,
r

r
P

log

yk

! ≥

Xk=1

Hence

where

r

log

wikhkj

Xk=1

! ≥

ck log(yk/ck)

Xk=1

r

Xk=1

as
ikj
bs
ij

log

bs
ij
as
ikj

wikhkj

,

!

ikj = ws
as

ikhs

kj and bs

ij =

and s indicates the current iteration.

ws

ikhs

kj,

r

Xk=1

 
 
 
 
Exercises

585

(b) Hence show that, ignoring constants, the function

g(W, H

|

Ws, Hs) =

N

p

r

uij

i=1
X

j=1
X
N

Xk=1
p

r

as
ikj
bs
ij

(cid:16)

log wik + log hkj

(cid:17)

wikhkj

−

i=1
X

j=1
X

Xk=1

minorizes L(W, H).

(c) Set the partial derivatives of g(W, H
derive the updating steps (14.74).

|

Ws, Hs) to zero and hence

Ex. 14.24 Consider the non-negative matrix factorization (14.72) in the
rank one case (r = 1).

(a) Show that the updates (14.74) reduce to

wi ←

wi

hj ←

hj

p
j=1 xij
p
j=1 wihj
P
N
i=1 xij
N
i=1 wihj
P

P

(14.121)

P
where wi = wi1, hj = h1j. This is an example of the iterative pro-
portional scaling procedure, applied to the independence model for a
two-way contingency table (Fienberg, 1977, for example).

(b) Show that the ﬁnal iterates have the explicit form

p
j=1 xij
p
j=1 xij

,

hk =

1
c ·

N
i=1 xik
p
j=1 xij

N
P
i=1

(14.122)

wi = c

N
i=1

· P
P

P

for any constant c > 0. These are equivalent to the usual row and
column estimates for a two-way independence model.

P

P

Ex. 14.25 Fit a non-negative matrix factorization model to the collection
of two’s in the digits database. Use 25 basis elements, and compare with a
24- component (plus mean) PCA model. In both cases display the W and
H matrices as in Figure 14.33.

586

14. Unsupervised Learning

15
Random Forests

This is page 587
Printer: Opaque this

15.1

Introduction

Bagging or bootstrap aggregation (section 8.7) is a technique for reducing
the variance of an estimated prediction function. Bagging seems to work
especially well for high-variance, low-bias procedures, such as trees. For
regression, we simply ﬁt the same regression tree many times to bootstrap-
sampled versions of the training data, and average the result. For classiﬁ-
cation, a committee of trees each cast a vote for the predicted class.

Boosting in Chapter 10 was initially proposed as a committee method as
well, although unlike bagging, the committee of weak learners evolves over
time, and the members cast a weighted vote. Boosting appears to dominate
bagging on most problems, and became the preferred choice.

Random forests (Breiman, 2001) is a substantial modiﬁcation of bagging
that builds a large collection of de-correlated trees, and then averages them.
On many problems the performance of random forests is very similar to
boosting, and they are simpler to train and tune. As a consequence, random
forests are popular, and are implemented in a variety of packages.

15.2 Deﬁnition of Random Forests

The essential idea in bagging (Section 8.7) is to average many noisy but
approximately unbiased models, and hence reduce the variance. Trees are
ideal candidates for bagging, since they can capture complex interaction

588

15. Random Forests

Algorithm 15.1 Random Forest for Regression or Classiﬁcation.

1. For b = 1 to B:

(a) Draw a bootstrap sample Z∗ of size N from the training data.

(b) Grow a random-forest tree Tb to the bootstrapped data, by re-
cursively repeating the following steps for each terminal node of
the tree, until the minimum node size nmin is reached.
i. Select m variables at random from the p variables.
ii. Pick the best variable/split-point among the m.
iii. Split the node into two daughter nodes.

2. Output the ensemble of trees

Tb}
{
To make a prediction at a new point x:

B
1 .

Regression: ˆf B

rf (x) = 1
B

B
b=1 Tb(x).

Classiﬁcation: Let ˆCb(x) be the class prediction of the bth random-forest

P

tree. Then ˆC B

rf (x) = majority vote

ˆCb(x)
{

B
1 .
}

structures in the data, and if grown suﬃciently deep, have relatively low
bias. Since trees are notoriously noisy, they beneﬁt greatly from the averag-
ing. Moreover, since each tree generated in bagging is identically distributed
(i.d.), the expectation of an average of B such trees is the same as the ex-
pectation of any one of them. This means the bias of bagged trees is the
same as that of the individual trees, and the only hope of improvement is
through variance reduction. This is in contrast to boosting, where the trees
are grown in an adaptive way to remove bias, and hence are not i.d.

An average of B i.i.d. random variables, each with variance σ2, has vari-
ance 1
B σ2. If the variables are simply i.d. (identically distributed, but not
necessarily independent) with positive pairwise correlation ρ, the variance
of the average is (Exercise 15.1)

ρσ2 +

ρ

σ2.

1

−
B

(15.1)

As B increases, the second term disappears, but the ﬁrst remains, and
hence the size of the correlation of pairs of bagged trees limits the beneﬁts
of averaging. The idea in random forests (Algorithm 15.1) is to improve
the variance reduction of bagging by reducing the correlation between the
trees, without increasing the variance too much. This is achieved in the
tree-growing process through random selection of the input variables.

Speciﬁcally, when growing a tree on a bootstrapped dataset:

Before each split, select m
as candidates for splitting.

≤

p of the input variables at random

15.2 Deﬁnition of Random Forests

589

Typically values for m are √p or even as low as 1.
T (x; Θb)
{

After B such trees

B
1 are grown, the random forest (regression)
}

predictor is

ˆf B
rf (x) =

1
B

B

Xb=1

T (x; Θb).

(15.2)

As in Section 10.9 (page 356), Θb characterizes the bth random forest tree in
terms of split variables, cutpoints at each node, and terminal-node values.
Intuitively, reducing m will reduce the correlation between any pair of trees
in the ensemble, and hence by (15.1) reduce the variance of the average.

Spam Data

Bagging
Random Forest
Gradient Boosting (5 Node)

r
o
r
r

E

t
s
e
T

0
7
0
.
0

5
6
0
.
0

0
6
0
.
0

5
5
0
.
0

0
5
0
.
0

5
4
0
.
0

0
4
0
.
0

0

500

1000

1500

2000

2500

Number of Trees

FIGURE 15.1. Bagging, random forest, and gradient boosting, applied to the
spam data. For boosting, 5-node trees were used, and the number of trees were
chosen by 10-fold cross-validation (2500 trees). Each “step” in the ﬁgure corre-
sponds to a change in a single misclassiﬁcation (in a test set of 1536).

Not all estimators can be improved by shaking up the data like this.
It seems that highly nonlinear estimators, such as trees, beneﬁt the most.
For bootstrapped trees, ρ is typically small (0.05 or lower is typical; see
Figure 15.9), while σ2 is not much larger than the variance for the original
tree. On the other hand, bagging does not change linear estimates, such
as the sample mean (hence its variance either); the pairwise correlation
between bootstrapped means is about 50% (Exercise 15.4).

 
590

15. Random Forests

Random forests are popular. Leo Breiman’s1 collaborator Adele Cutler
maintains a random forest website2 where the software is freely available,
with more than 3000 downloads reported by 2002. There is a randomForest
package in R, maintained by Andy Liaw, available from the CRAN website.
The authors make grand claims about the success of random forests:
“most accurate,” “most interpretable,” and the like. In our experience ran-
dom forests do remarkably well, with very little tuning required. A ran-
dom forest classiﬁer achieves 4.88% misclassiﬁcation error on the spam test
data, which compares well with all other methods, and is not signiﬁcantly
worse than gradient boosting at 4.5%. Bagging achieves 5.4% which is
signiﬁcantly worse than either (using the McNemar test outlined in Ex-
ercise 10.6), so it appears on this example the additional randomization
helps.

Nested Spheres

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

i

l

t
s
e
T

5
1
.
0

0
1
.
0

5
0
.
0

0
0
.
0

Bayes Error

RF−1

RF−3

Bagging

GBM−1

GBM−6

FIGURE 15.2. The results of 50 simulations from the “nested spheres” model in
IR10. The Bayes decision boundary is the surface of a sphere (additive). “RF-3”
refers to a random forest with m = 3, and “GBM-6” a gradient boosted model
with interaction order six; similarly for “RF-1” and “GBM-1.” The training sets
were of size 2000, and the test sets 10, 000.

Figure 15.1 shows the test-error progression on 2500 trees for the three
methods. In this case there is some evidence that gradient boosting has
started to overﬁt, although 10-fold cross-validation chose all 2500 trees.

1Sadly, Leo Breiman died in July, 2005.
2http://www.math.usu.edu/∼adele/forests/

 
 
15.2 Deﬁnition of Random Forests

591

California Housing Data

RF m=2
RF m=6
GBM depth=4
GBM depth=6

r
o
r
r

l

E
e
t
u
o
s
b
A
e
g
a
r
e
v
A

t
s
e
T

4
4
.
0

2
4
.
0

0
4
.
0

8
3
.
0

6
3
.
0

4
3
.
0

2
3
.
0

0

200

400

600

800

1000

Number of Trees

FIGURE 15.3. Random forests compared to gradient boosting on the California
housing data. The curves represent mean absolute error on the test data as a
function of the number of trees in the models. Two random forests are shown, with
m = 2 and m = 6. The two gradient boosted models use a shrinkage parameter
ν = 0.05 in (10.41), and have interaction depths of 4 and 6. The boosted models
outperform random forests.

Figure 15.2 shows the results of a simulation3 comparing random forests
to gradient boosting on the nested spheres problem [Equation (10.2) in
Chapter 10]. Boosting easily outperforms random forests here. Notice that
smaller m is better here, although part of the reason could be that the true
decision boundary is additive.

Figure 15.3 compares random forests to boosting (with shrinkage) in a
regression problem, using the California housing data (Section 10.14.1).
Two strong features that emerge are

•

Random forests stabilize at about 200 trees, while at 1000 trees boost-
ing continues to improve. Boosting is slowed down by the shrinkage,
as well as the fact that the trees are much smaller.

•

Boosting outperforms random forests here. At 1000 terms, the weaker
boosting model (GBM depth 4) has a smaller error than the stronger

3Details: The random forests were ﬁt using the R package randomForest 4.5-11,
with 500 trees. The gradient boosting models were ﬁt using R package gbm 1.5, with
shrinkage parameter set to 0.05, and 2000 trees.

 
 
 
592

15. Random Forests

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

l

i

OOB Error
Test Error

5
7
0
.
0

5
6
0
.
0

5
5
0
.
0

5
4
0
.
0

0

500

1000

1500

2000

2500

Number of Trees

FIGURE 15.4. oob error computed on the spam training data, compared to the
test error computed on the test set.

random forest (RF m = 6); a Wilcoxon test on the mean diﬀerences
in absolute errors has a p-value of 0.007. For larger m the random
forests performed no better.

15.3 Details of Random Forests

We have glossed over the distinction between random forests for classiﬁca-
tion versus regression. When used for classiﬁcation, a random forest obtains
a class vote from each tree, and then classiﬁes using majority vote (see Sec-
tion 8.7 on bagging for a similar discussion). When used for regression, the
predictions from each tree at a target point x are simply averaged, as in
(15.2). In addition, the inventors make the following recommendations:

•

•

For classiﬁcation, the default value for m is
node size is one.

√p

⌋

⌊

and the minimum

For regression, the default value for m is
node size is ﬁve.

p/3
⌋

⌊

and the minimum

In practice the best values for these parameters will depend on the problem,
and they should be treated as tuning parameters. In Figure 15.3 m = 6
performs much better than the default value

= 2.

8/3

⌊

⌋

15.3.1 Out of Bag Samples
An important feature of random forests is its use of out-of-bag (oob) sam-
ples:

 
15.3 Details of Random Forests

593

For each observation zi = (xi, yi), construct its random forest
predictor by averaging only those trees corresponding to boot-
strap samples in which zi did not appear.

An oob error estimate is almost identical to that obtained by N -fold cross-
validation; see Exercise 15.2. Hence unlike many other nonlinear estimators,
random forests can be ﬁt in one sequence, with cross-validation being per-
formed along the way. Once the oob error stabilizes, the training can be
terminated.

Figure 15.4 shows the oob misclassiﬁcation error for the spam data, com-
pared to the test error. Although 2500 trees are averaged here, it appears
from the plot that about 200 would be suﬃcient.

15.3.2 Variable Importance

Variable importance plots can be constructed for random forests in exactly
the same way as they were for gradient-boosted models (Section 10.13).
At each split in each tree, the improvement in the split-criterion is the
importance measure attributed to the splitting variable, and is accumulated
over all the trees in the forest separately for each variable. The left plot
of Figure 15.5 shows the variable importances computed in this way for
the spam data; compare with the corresponding Figure 10.6 on page 354 for
gradient boosting. Boosting ignores some variables completely, while the
random forest does not. The candidate split-variable selection increases
the chance that any single variable gets included in a random forest, while
no such selection occurs with boosting.

Random forests also use the oob samples to construct a diﬀerent variable-
importance measure, apparently to measure the prediction strength of each
variable. When the bth tree is grown, the oob samples are passed down
the tree, and the prediction accuracy is recorded. Then the values for the
jth variable are randomly permuted in the oob samples, and the accuracy
is again computed. The decrease in accuracy as a result of this permuting
is averaged over all trees, and is used as a measure of the importance of
variable j in the random forest. These are expressed as a percent of the
maximum in the right plot in Figure 15.5. Although the rankings of the
two methods are similar, the importances in the right plot are more uni-
form over the variables. The randomization eﬀectively voids the eﬀect of
a variable, much like setting a coeﬃcient to zero in a linear model (Exer-
cise 15.7). This does not measure the eﬀect on prediction were this variable
not available, because if the model was reﬁtted without the variable, other
variables could be used as surrogates.

594

15. Random Forests

Gini

Randomization

table
parts
cs
3d
addresses
857
415
direct
conference
project
original
report
telnet
lab
[
85
technology
data
font
credit
#
make
people
pm
address
order
labs
meeting
650
;
mail
over
receive
re
email
all
will
(
internet
1999
business
hpl
edu
000
george
you
our
money
CAPTOT
hp
CAPMAX
your
CAPAVE
free
remove
$
!

table
parts
3d
addresses
direct
report
cs
make
415
#
857
conference
credit
data
project
people
telnet
lab
original
address
85
[
labs
all
order
technology
mail
font
;
email
over
receive
pm
650
internet
will
(
money
meeting
000
business
hpl
you
re
1999
our
your
CAPTOT
george
edu
CAPMAX
free
hp
CAPAVE
$
remove
!

0

20

40

60

80

100

0

20

40

60

80

100

Variable Importance

Variable Importance

FIGURE 15.5. Variable importance plots for a classiﬁcation random forest
grown on the spam data. The left plot bases the importance on the Gini split-
ting index, as in gradient boosting. The rankings compare well with the rankings
produced by gradient boosting (Figure 10.6 on page 354). The right plot uses oob
randomization to compute variable importances, and tends to spread the impor-
tances more uniformly.

15.3 Details of Random Forests

595

Proximity Plot

Random Forest Classifier

2

3

1

2

n
o
i
s
n
e
m
D

i

4

5

6

2
X

6

5

3

4

2

1

Dimension 1

X1

FIGURE 15.6. (Left): Proximity plot for a random forest classiﬁer grown to
the mixture data. (Right): Decision boundary and training data for random forest
on mixture data. Six points have been identiﬁed in each plot.

15.3.3 Proximity Plots

One of the advertised outputs of a random forest is a proximity plot. Fig-
ure 15.6 shows a proximity plot for the mixture data deﬁned in Section 2.3.3
N proximity matrix is
in Chapter 2. In growing a random forest, an N
accumulated for the training data. For every tree, any pair of oob obser-
vations sharing a terminal node has their proximity increased by one. This
proximity matrix is then represented in two dimensions using multidimen-
sional scaling (Section 14.8). The idea is that even though the data may be
high-dimensional, involving mixed variables, etc., the proximity plot gives
an indication of which observations are eﬀectively close together in the eyes
of the random forest classiﬁer.

×

Proximity plots for random forests often look very similar, irrespective of
the data, which casts doubt on their utility. They tend to have a star shape,
one arm per class, which is more pronounced the better the classiﬁcation
performance.

Since the mixture data are two-dimensional, we can map points from the
proximity plot to the original coordinates, and get a better understanding of
what they represent. It seems that points in pure regions class-wise map to
the extremities of the star, while points nearer the decision boundaries map
nearer the center. This is not surprising when we consider the construction
of the proximity matrices. Neighboring points in pure regions will often
end up sharing a bucket, since when a terminal node is pure, it is no longer

596

15. Random Forests

split by a random forest tree-growing algorithm. On the other hand, pairs
of points that are close but belong to diﬀerent classes will sometimes share
a terminal node, but not always.

15.3.4 Random Forests and Overﬁtting

When the number of variables is large, but the fraction of relevant variables
small, random forests are likely to perform poorly with small m. At each
split the chance can be small that the relevant variables will be selected.
Figure 15.7 shows the results of a simulation that supports this claim. De-
tails are given in the ﬁgure caption and Exercise 15.3. At the top of each
pair we see the hyper-geometric probability that a relevant variable will be
selected at any split by a random forest tree (in this simulation, the relevant
variables are all equal in stature). As this probability gets small, the gap
between boosting and random forests increases. When the number of rele-
vant variables increases, the performance of random forests is surprisingly
robust to an increase in the number of noise variables. For example, with 6
relevant and 100 noise variables, the probability of a relevant variable being
10. According to
selected at any split is 0.46, assuming m =
Figure 15.7, this does not hurt the performance of random forests compared
with boosting. This robustness is largely due to the relative insensitivity of
misclassiﬁcation cost to the bias and variance of the probability estimates
in each tree. We consider random forests for regression in the next section.

(6 + 100)

p

≈

Another claim is that random forests “cannot overﬁt” the data. It is
certainly true that increasing B does not cause the random forest sequence
to overﬁt; like bagging, the random forest estimate (15.2) approximates the
expectation

ˆfrf (x) = EΘT (x; Θ) = lim
B→∞

ˆf (x)B
rf

(15.3)

with an average over B realizations of Θ. The distribution of Θ here is con-
ditional on the training data. However, this limit can overﬁt the data; the
average of fully grown trees can result in too rich a model, and incur unnec-
essary variance. Segal (2004) demonstrates small gains in performance by
controlling the depths of the individual trees grown in random forests. Our
experience is that using full-grown trees seldom costs much, and results in
one less tuning parameter.

Figure 15.8 shows the modest eﬀect of depth control in a simple regression
example. Classiﬁers are less sensitive to variance, and this eﬀect of over-
ﬁtting is seldom seen with random-forest classiﬁcation.

15.4 Analysis of Random Forests

597

0.52

0.34

0.25

0.19

0.15

Random Forest
Gradient Boosting

Bayes Error

(2, 5)

(2, 25)

(2, 50)

(2, 100)

(2, 150)

Number of (Relevant, Noise) Variables

0
3
.
0

5
2
.
0

0
2
.
0

5
1
.
0

0
1
0

.

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

l

i

t
s
e
T

FIGURE 15.7. A comparison of random forests and gradient boosting on prob-
lems with increasing numbers of noise variables. In each case the true decision
boundary depends on two variables, and an increasing number of noise variables
are included. Random forests uses its default value m = √p. At the top of each
pair is the probability that one of the relevant variables is chosen at any split.
The results are based on 50 simulations for each pair, with a training sample of
300, and a test sample of 500.

15.4 Analysis of Random Forests

In this section we analyze the mechanisms at play with the additional
randomization employed by random forests. For this discussion we focus
on regression and squared error loss, since this gets at the main points,
and bias and variance are more complex with 0–1 loss (see Section 7.3.1).
Furthermore, even in the case of a classiﬁcation problem, we can consider
the random-forest average as an estimate of the class posterior probabilities,
for which bias and variance are appropriate descriptors.

15.4.1 Variance and the De-Correlation Eﬀect

The limiting form (B

→ ∞

) of the random forest regression estimator is

ˆfrf (x) = EΘ|ZT (x; Θ(Z)),

(15.4)

where we have made explicit the dependence on the training data Z. Here
we consider estimation at a single target point x. From (15.1) we see that

 
 
598

15. Random Forests

Shallow

Deep

r
o
r
r

E

t
s
e
T
d
e
r
a
u
q
S
n
a
e
M

0
1
.
1

5
0
.
1

0
0
.
1

50

30

20

10

5

Minimum Node Size

FIGURE 15.8. The eﬀect of tree size on the error in random forest regres-
sion. In this example, the true surface was additive in two of the 12 variables,
plus additive unit-variance Gaussian noise. Tree depth is controlled here by the
minimum node size; the smaller the minimum node size, the deeper the trees.

Var ˆfrf (x) = ρ(x)σ2(x).

(15.5)

Here

•

ρ(x) is the sampling correlation between any pair of trees used in the
averaging:

ρ(x) = corr[T (x; Θ1(Z)), T (x; Θ2(Z))],

(15.6)

where Θ1(Z) and Θ2(Z) are a randomly drawn pair of random forest
trees grown to the randomly sampled Z;

σ2(x) is the sampling variance of any single randomly drawn tree,

•

σ2(x) = Var T (x; Θ(Z)).

(15.7)

It is easy to confuse ρ(x) with the average correlation between ﬁtted trees
in a given random-forest ensemble; that is, think of the ﬁtted trees as N -
vectors, and compute the average pairwise correlation between these vec-
tors, conditioned on the data. This is not the case; this conditional corre-
lation is not directly relevant in the averaging process, and the dependence
on x in ρ(x) warns us of the distinction. Rather, ρ(x) is the theoretical
correlation between a pair of random-forest trees evaluated at x, induced
by repeatedly making training sample draws Z from the population, and
then drawing a pair of random forest trees. In statistical jargon, this is the
correlation induced by the sampling distribution of Z and Θ.

More precisely, the variability averaged over in the calculations in (15.6)

and (15.7) is both

 
 
 
15.4 Analysis of Random Forests

599

conditional on Z: due to the bootstrap sampling and feature sampling
at each split, and

a result of the sampling variability of Z itself.

•

•

In fact, the conditional covariance of a pair of tree ﬁts at x is zero, because
the bootstrap and feature sampling is i.i.d; see Exercise 15.5.

s
e
e
r
T
n
e
e
w
t
e
b
n
o
i
t
a
e
r
r
o
C

l

8
0
.
0

6
0
.
0

4
0
.
0

2
0
.
0

0
0
.
0

1 4 7

13

19

25

31

37

43

49

Number of Randomly Selected Splitting Variables m

FIGURE 15.9. Correlations between pairs of trees drawn by a random-forest
regression algorithm, as a function of m. The boxplots represent the correlations
at 600 randomly chosen prediction points x.

The following demonstrations are based on a simulation model

Y =

1
√50

50

Xj + ε,

(15.8)

j=1
X
with all the Xj and ε iid Gaussian. We use 500 training sets of size 100, and
a single set of test locations of size 600. Since regression trees are nonlinear
in Z, the patterns we see below will diﬀer somewhat depending on the
structure of the model.

Figure 15.9 shows how the correlation (15.6) between pairs of trees de-
creases as m decreases: pairs of tree predictions at x for diﬀerent training
sets Z are likely to be less similar if they do not use the same splitting
variables.

In the left panel of Figure 15.10 we consider the variances of single tree
predictors, VarT (x; Θ(Z)) (averaged over 600 prediction points x drawn
randomly from our simulation model). This is the total variance, and can be

 
 
600

15. Random Forests

decomposed into two parts using standard conditional variance arguments
(see Exercise 15.5):

VarΘ,ZT (x; Θ(Z)) = VarZEΘ|ZT (x; Θ(Z)) + EZVarΘ|ZT (x; Θ(Z))
VarZ ˆfrf (x)

within-Z Variance

Total Variance

+

=

(15.9)
The second term is the within-Z variance—a result of the randomization,
which increases as m decreases. The ﬁrst term is in fact the sampling vari-
ance of the random forest ensemble (shown in the right panel), which de-
creases as m decreases. The variance of the individual trees does not change
appreciably over much of the range of m, hence in light of (15.5), the vari-
ance of the ensemble is dramatically lower than this tree variance.

Single Tree

Random Forest Ensemble

i

s
a
B
d
e
r
a
u
q
S
d
n
a

r
o
r
r

E
d
e
r
a
u
q
S
n
a
e
M

5
8
.
0

0
8
.
0

5
7
.
0

0
7
.
0

5
6
.
0

Within Z
Total

Mean Squared Error
Squared Bias
Variance

0
2
.
0

5
1
.
0

0
1
.
0

5
0
.
0

0
.
0

e
c
n
a
i
r
a
V

e
c
n
a
i
r
a
V

5
9
.
1

0
9
.
1

5
8
.
1

0
8
.
1

0

10

20

30

40

50

0

10

20

30

40

50

m

m

FIGURE 15.10. Simulation results. The left panel shows the average variance of
a single random forest tree, as a function of m. “Within Z” refers to the average
within-sample contribution to the variance, resulting from the bootstrap sampling
and split-variable sampling (15.9). “Total” includes the sampling variability of
Z. The horizontal line is the average variance of a single fully grown tree (with-
out bootstrap sampling). The right panel shows the average mean-squared error,
squared bias and variance of the ensemble, as a function of m. Note that the
variance axis is on the right (same scale, diﬀerent level). The horizontal line is
the average squared-bias of a fully grown tree.

15.4.2 Bias

As in bagging, the bias of a random forest is the same as the bias of any
of the individual sampled trees T (x; Θ(Z)):

 
 
 
 
 
15.4 Analysis of Random Forests

601

EZ ˆfrf (x)
EZEΘ|ZT (x; Θ(Z)).

Bias(x) = µ(x)
= µ(x)

−
−
This is also typically greater (in absolute terms) than the bias of an un-
pruned tree grown to Z, since the randomization and reduced sample space
impose restrictions. Hence the improvements in prediction obtained by bag-
ging or random forests are solely a result of variance reduction.

(15.10)

Any discussion of bias depends on the unknown true function. Fig-
ure 15.10 (right panel) shows the squared bias for our additive model simu-
lation (estimated from the 500 realizations). Although for diﬀerent models
the shape and rate of the bias curves may diﬀer, the general trend is that
as m decreases, the bias increases. Shown in the ﬁgure is the mean-squared
error, and we see a classical bias-variance trade-oﬀ in the choice of m. For
all m the squared bias of the random forest is greater than that for a single
tree (horizontal line).

These patterns suggest a similarity with ridge regression (Section 3.4.1).
Ridge regression is useful (in linear models) when one has a large number
of variables with similarly sized coeﬃcients; ridge shrinks their coeﬃcients
toward zero, and those of strongly correlated variables toward each other.
Although the size of the training sample might not permit all the variables
to be in the model, this regularization via ridge stabilizes the model and al-
lows all the variables to have their say (albeit diminished). Random forests
with small m perform a similar averaging. Each of the relevant variables
get their turn to be the primary split, and the ensemble averaging reduces
the contribution of any individual variable. Since this simulation exam-
ple (15.8) is based on a linear model in all the variables, ridge regression
achieves a lower mean-squared error (about 0.45 with df(λopt)

29).

≈

15.4.3 Adaptive Nearest Neighbors

The random forest classiﬁer has much in common with the k-nearest neigh-
bor classiﬁer (Section 13.3); in fact a weighted version thereof. Since each
tree is grown to maximal size, for a particular Θ∗, T (x; Θ∗(Z)) is the re-
sponse value for one of the training samples4. The tree-growing algorithm
ﬁnds an “optimal” path to that observation, choosing the most informative
predictors from those at its disposal. The averaging process assigns weights
to these training responses, which ultimately vote for the prediction. Hence
via the random-forest voting mechanism, those observations close to the
target point get assigned weights—an equivalent kernel—which combine to
form the classiﬁcation decision.

Figure 15.11 demonstrates the similarity between the decision boundary

of 3-nearest neighbors and random forests on the mixture data.

4We gloss over the fact that pure nodes are not split further, and hence there can be

more than one observation in a terminal node

602

15. Random Forests

Random Forest Classifier

3−Nearest Neighbors

o
o

o

o

o
o
o
o
o

o
o
o

o
o

o

o

o

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o

o
o
o
o
o
o
o
o

o
o

o
o

o

o

o

o

Training Error: 0.000
Test Error:       0.238
Bayes Error:    0.210

o

o

o
o

o
o
o
o
o
o
o
o
o
o
o

o
o
o

o

o
o
o

o
o

o
o
o
o
o

o
o

o

o

o
o
o
o
o

o
o
o

o

o
o
oo

o

o
o

o

o

o

o

o

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
o
o
o
o
o
o
o
o
o
o
o

o
o
o
o
o
o
o
o

o
o

o
o

o

o

o

o

o

o
o

o
o
o
o
o
o
o
o
o
o
o

o
o
o

o

o

o
o
oo

o

o
o
o

o
o

o
o
o
o
o

Training Error: 0.130
Test Error:       0.242
Bayes Error:    0.210

o

FIGURE 15.11. Random forests versus 3-NN on the mixture data. The axis-ori-
ented nature of the individual trees in a random forest lead to decision regions
with an axis-oriented ﬂavor.

Bibliographic Notes

Random forests as described here were introduced by Breiman (2001), al-
though many of the ideas had cropped up earlier in the literature in dif-
ferent forms. Notably Ho (1995) introduced the term “random forest,” and
used a consensus of trees grown in random subspaces of the features. The
idea of using stochastic perturbation and averaging to avoid overﬁtting was
introduced by Kleinberg (1990), and later in Kleinberg (1996). Amit and
Geman (1997) used randomized trees grown on image features for image
classiﬁcation problems. Breiman (1996a) introduced bagging, a precursor
to his version of random forests. Dietterich (2000b) also proposed an im-
provement on bagging using additional randomization. His approach was
to rank the top 20 candidate splits at each node, and then select from the
list at random. He showed through simulations and real examples that this
additional randomization improved over the performance of bagging. Fried-
man and Hall (2007) showed that sub-sampling (without replacement) is
an eﬀective alternative to bagging. They showed that growing and aver-
aging trees on samples of size N/2 is approximately equivalent (in terms
bias/variance considerations) to bagging, while using smaller fractions of
N reduces the variance even further (through decorrelation).

There are several free software implementations of random forests. In
this chapter we used the randomForest package in R, maintained by Andy
Liaw, available from the CRAN website. This allows both split-variable se-
lection, as well as sub-sampling. Adele Cutler maintains a random forest
adele/forests/ where (as of Au-
website http://www.math.usu.edu/
∼
gust 2008) the software written by Leo Breiman and Adele Cutler is freely

Exercises

603

available. Their code, and the name “random forests”, is exclusively li-
censed to Salford Systems for commercial release. The Weka machine learn-
ing archive http://www.cs.waikato.ac.nz/ml/weka/ at Waikato Univer-
sity, New Zealand, oﬀers a free java implementation of random forests.

Exercises

Ex. 15.1 Derive the variance formula (15.1). This appears to fail if ρ is
negative; diagnose the problem in this case.

Ex. 15.2 Show that as the number of bootstrap samples B gets large, the
oob error estimate for a random forest approaches its N -fold CV error
estimate, and that in the limit, the identity is exact.

Ex. 15.3 Consider the simulation model used in Figure 15.7 (Mease and
Wyner, 2008). Binary observations are generated with probabilities

J

Pr(Y = 1
|

X) = q + (1

2q)

1


·

−

Xj > J/2



,

(15.11)


1
where X
2 , and J
number. Describe this probability surface, and give the Bayes error rate.

p is some predeﬁned (even)

U [0, 1]p, 0

≤

≤

≤

∼



q

j=1
X

Ex. 15.4 Suppose xi, i = 1, . . . , N are iid (µ, σ2). Let ¯x∗
2 be two
bootstrap realizations of the sample mean. Show that the sampling cor-
relation corr(¯x∗
1) and
the variance of the bagged mean ¯xbag. Here ¯x is a linear statistic; bagging
produces no reduction in variance for linear statistics.

50%. Along the way, derive var(¯x∗

2) = n

1 and ¯x∗

2n−1 ≈

1, ¯x∗

Ex. 15.5 Show that the sampling correlation between a pair of random-
forest trees at a point x is given by

ρ(x) =

VarZ[EΘ|ZT (x; Θ(Z))]
VarZ[EΘ|ZT (x; Θ(Z))] + EZVarΘ|Z[T (x; Θ(Z)]

.

(15.12)

The term in the numerator is VarZ[ ˆfrf (x)], and the second term in the
denominator is the expected conditional variance due to the randomization
in random forests.

Ex. 15.6 Fit a series of random-forest classiﬁers to the spam data, to explore
the sensitivity to the parameter m. Plot both the oob error as well as the
test error against a suitably chosen range of values for m.

604

15. Random Forests

Ex. 15.7 Suppose we ﬁt a linear regression model to N observations with
response yi and predictors xi1, . . . , xip. Assume that all variables are stan-
dardized to have mean zero and standard deviation one. Let RSS be the
mean-squared residual on the training data, and ˆβ the estimated coeﬃcient.
Denote by RSS∗
j the mean-squared residual on the training data using the
same ˆβ, but with the N values for the jth variable randomly permuted
before the predictions are calculated. Show that

EP [RSS∗

j −

RSS] = 2 ˆβ2
j ,

(15.13)

where EP denotes expectation with respect to the permutation distribution.
Argue that this is approximately true when the evaluations are done using
an independent test set.

16
Ensemble Learning

This is page 605
Printer: Opaque this

16.1

Introduction

The idea of ensemble learning is to build a prediction model by combining
the strengths of a collection of simpler base models. We have already seen
a number of examples that fall into this category.

Bagging in Section 8.7 and random forests in Chapter 15 are ensemble
methods for classiﬁcation, where a committee of trees each cast a vote for
the predicted class. Boosting in Chapter 10 was initially proposed as a
committee method as well, although unlike random forests, the committee
of weak learners evolves over time, and the members cast a weighted vote.
Stacking (Section 8.8) is a novel approach to combining the strengths of
a number of ﬁtted models. In fact one could characterize any dictionary
method, such as regression splines, as an ensemble method, with the basis
functions serving the role of weak learners.

Bayesian methods for nonparametric regression can also be viewed as
ensemble methods: a large number of candidate models are averaged with
respect to the posterior distribution of their parameter settings (e.g. (Neal
and Zhang, 2006)).

Ensemble learning can be broken down into two tasks: developing a pop-
ulation of base learners from the training data, and then combining them
to form the composite predictor. In this chapter we discuss boosting tech-
nology that goes a step further; it builds an ensemble model by conducting
a regularized and supervised search in a high-dimensional space of weak
learners.

606

16. Ensemble Learning

An early example of a learning ensemble is a method designed for multi-
class classiﬁcation using error-correcting output codes (Dietterich and Bakiri,
1995, ECOC). Consider the 10-class digit classiﬁcation problem, and the
coding matrix C given in Table 16.1.

TABLE 16.1. Part of a 15-bit error-correcting coding matrix C for the 10-class
digit classiﬁcation problem. Each column deﬁnes a two-class classiﬁcation prob-
lem.

Digit
0
1
2
..
.
8
9

C1
1
0
1
..
.
1
0

C2
1
0
0
..
.
1
1

C3
0
1
0
..
.
0
1

C4
0
1
1
..
.
1
1

C5
0
1
0
..
.
0
0

C6
0
1
0
..
.
1
0

· · ·
· · ·
· · ·
· · ·

· · ·
· · ·
· · ·

C15
1
0
1
..
.
1
0

Note that the ℓth column of the coding matrix Cℓ deﬁnes a two-class
variable that merges all the original classes into two groups. The method
works as follows:

1. Learn a separate classiﬁer for each of the L = 15 two class problems

deﬁned by the columns of the coding matrix.

2. At a test point x, let ˆpℓ(x) be the predicted probability of a one for

the ℓth response.

3. Deﬁne δk(x) =

, the discriminant function for the
|
kth class, where Ckℓ is the entry for row k and column ℓ in Table 16.1.

Ckℓ −

ˆpℓ(x)

L
ℓ=1 |

P

Each row of C is a binary code for representing that class. The rows have
more bits than is necessary, and the idea is that the redundant “error-
correcting” bits allow for some inaccuracies, and can improve performance.
In fact, the full code matrix C above has a minimum Hamming distance1
of 7 between any pair of rows. Note that even the indicator response coding
(Section 4.2) is redundant, since 10 classes require only
log2 10 = 4 bits for
their unique representation. Dietterich and Bakiri (1995) showed impressive
improvements in performance for a variety of multiclass problems when
classiﬁcation trees were used as the base classiﬁer.

⌈

James and Hastie (1998) analyzed the ECOC approach, and showed
that random code assignment worked as well as the optimally constructed
error-correcting codes. They also argued that the main beneﬁt of the coding
was in variance reduction (as in bagging and random forests), because the
diﬀerent coded problems resulted in diﬀerent trees, and the decoding step
(3) above has a similar eﬀect as averaging.

1The Hamming distance between two vectors is the number of mismatches between

corresponding entries.

16.2 Boosting and Regularization Paths

607

16.2 Boosting and Regularization Paths

In Section 10.12.2 of the ﬁrst edition of this book, we suggested an analogy
between the sequence of models produced by a gradient boosting algorithm
and regularized model ﬁtting in high-dimensional feature spaces. This was
primarily motivated by observing the close connection between a boosted
version of linear regression and the lasso (Section 3.4.2). These connec-
tions have been pursued by us and others, and here we present our current
thinking in this area. We start with the original motivation, which ﬁts more
naturally in this chapter on ensemble learning.

16.2.1 Penalized Regression

Intuition for the success of the shrinkage strategy (10.41) of gradient boost-
ing (page 364 in Chapter 10) can be obtained by drawing analogies with
penalized linear regression with a large basis expansion. Consider the dic-
tionary of all possible J-terminal node regression trees
that could
be realized on the training data as basis functions in IRp. The linear model
is

Tk}
{

=

T

K

f (x) =

αkTk(x),

Xk=1

(16.1)

where K = card(
). Suppose the coeﬃcients are to be estimated by least
squares. Since the number of such trees is likely to be much larger than
even the largest training data sets, some form of regularization is required.
Let ˆα(λ) solve

T

N

K

min

α 


i=1  
X

yi −

Xk=1

αkTk(xi)

2

!

+ λ

·

J(α)

,




(16.2)

J(α) is a function of the coeﬃcients that generally penalizes larger values.
Examples are





J(α) =

J(α) =

K

Xk=1
K

Xk=1

2

αk|

|

αk|

|

ridge regression,

(16.3)

lasso,

(16.4)

(16.5)

both covered in Section 3.4. As discussed there, the solution to the lasso
problem with moderate to large λ tends to be sparse; many of the ˆαk(λ) =
0. That is, only a small fraction of all possible trees enter the model (16.1).

608

16. Ensemble Learning

Algorithm 16.1 Forward Stagewise Linear Regression.

1. Initialize ˇαk = 0, k = 1, . . . , K. Set ε > 0 to some small constant,

and M large.

2. For m = 1 to M :

(a) (β∗, k∗) = arg minβ,k

N
i=1

(b) ˇαk∗

ˇαk∗ + ε

←

3. Output fM (x) =

P

sign(β∗).

P

·
K
k=1 ˇαkTk(x).

yi −

(cid:16)

K
l=1 ˇαlTl(xi)

βTk(xi)

−

2

.

(cid:17)

P

This seems reasonable since it is likely that only a small fraction of all pos-
sible trees will be relevant in approximating any particular target function.
However, the relevant subset will be diﬀerent for diﬀerent targets. Those
coeﬃcients that are not set to zero are shrunk by the lasso in that their
absolute values are smaller than their corresponding least squares values2:
. As λ increases, the coeﬃcients all shrink, each one
ˆαk(λ)
|
|
ultimately becoming zero.

ˆαk(0)

<

|

|

Owing to the very large number of basis functions Tk, directly solving
(16.2) with the lasso penalty (16.4) is not possible. However, a feasible
forward stagewise strategy exists that closely approximates the eﬀect of
the lasso, and is very similar to boosting and the forward stagewise Algo-
rithm 10.2. Algorithm 16.1 gives the details. Although phrased in terms
of tree basis functions Tk, the algorithm can be used with any set of ba-
sis functions. Initially all coeﬃcients are zero in line 1; this corresponds
to λ =
in (16.2). At each successive step, the tree Tk∗ is selected that
best ﬁts the current residuals in line 2(a). Its corresponding coeﬃcient ˇαk∗
is then incremented or decremented by an inﬁnitesimal amount in 2(b),
= k∗ are left unchanged. In principle, this
while all other coeﬃcients ˇαk, k
process could be iterated until either all the residuals are zero, or β∗ = 0.
The latter case can occur if K < N , and at that point the coeﬃcient values
represent a least squares solution. This corresponds to λ = 0 in (16.2).

∞

After applying Algorithm 16.1 with M <

iterations, many of the coef-
ﬁcients will be zero, namely, those that have yet to be incremented. The oth-
ers will tend to have absolute values smaller than their corresponding least
squares solution values,
. Therefore this M -iteration
<
solution qualitatively resembles the lasso, with M inversely related to λ.

ˇαk(M )

ˆαk(0)

∞

|

|

|

|

Figure 16.1 shows an example, using the prostate data studied in Chap-
ter 3. Here, instead of using trees Tk(X) as basis functions, we use the origi-

2If K > N , there is in general no unique “least squares value,” since inﬁnitely many
solutions will exist that ﬁt the data perfectly. We can pick the minimum L1-norm solution
amongst these, which is the unique lasso solution.

6
16.2 Boosting and Regularization Paths

609

Lasso

Forward Stagewise

lcavol

lcavol

s
t
n
e
i
c
ﬃ
e
o
C

6
.
0

4
.
0

2
.
0

0
.
0

2
.
0
−

s
t
n
e
i
c
ﬃ
e
o
C

6
.
0

4
.
0

2
.
0

0
.
0

2
.
0
−

svi
lweight
pgg45
lbph

gleason

age

lcp

svi
lweight
pgg45
lbph

gleason

age

lcp

0.0

0.5

1.0

1.5

2.0

0

50

100

150

200

t =

Pk |

αk

|

Iteration

FIGURE 16.1. Proﬁles of estimated coeﬃcients from linear regression, for the
prostate data studied in Chapter 3. The left panel shows the results from the lasso,
. The right panel shows
for diﬀerent values of the bound parameter t =
the results of the stagewise linear regression Algorithm 16.1, using M = 220
consecutive steps of size ε = .01.

Pk |

αk

|

nal variables Xk themselves; that is, a multiple linear regression model. The
left panel displays the proﬁles of estimated coeﬃcients from the lasso, for
. The right panel shows
diﬀerent values of the bound parameter t =
the results of the stagewise Algorithm 16.1, with M = 250 and ε = 0.01.
[The left and right panels of Figure 16.1 are the same as Figure 3.10 and
the left panel of Figure 3.19, respectively.] The similarity between the two
graphs is striking.

αk|

k |

P

In some situations the resemblance is more than qualitative. For example,

0, M

if all of the basis functions Tk are mutually uncorrelated, then as ε
↑
t, Algorithm 16.1 yields exactly the same solution as the
such that M ǫ
→
lasso for bound parameter t =
(and likewise for all solutions along
αk|
the path). Of course, tree-based regressors are not uncorrelated. However,
the solution sets are also identical if the coeﬃcients ˆαk(λ) are all monotone
functions of λ. This is often the case when the correlation between the
variables is low. When the ˆαk(λ) are not monotone in λ, then the solution
sets are not identical. The solution sets for Algorithm 16.1 tend to change
less rapidly with changing values of the regularization parameter than those
of the lasso.

k |

P

↓

610

16. Ensemble Learning

Efron et al. (2004) make the connections more precise, by characterizing
the exact solution paths in the ε-limiting case. They show that the coeﬃ-
cient paths are piece-wise linear functions, both for the lasso and forward
stagewise. This facilitates eﬃcient algorithms which allow the entire paths
to be computed with the same cost as a single least-squares ﬁt. This least
angle regression algorithm is described in more detail in Section 3.8.1.

Hastie et al. (2007) show that this inﬁnitesimal forward stagewise algo-
rithm (FS0) ﬁts a monotone version of the lasso, which optimally reduces
at each step the loss function for a given increase in the arc length of the
coeﬃcient path (see Sections 16.2.3 and 3.8.1). The arc-length for the ǫ > 0
case is M ǫ, and hence proportional to the number of steps.

Tree boosting (Algorithm 10.3) with shrinkage (10.41) closely resembles
Algorithm 16.1, with the learning rate parameter ν corresponding to ε. For
squared error loss, the only diﬀerence is that the optimal tree to be selected
at each iteration Tk∗ is approximated by the standard top-down greedy
tree-induction algorithm. For other loss functions, such as the exponential
loss of AdaBoost and the binomial deviance, Rosset et al. (2004a) show
similar results to what we see here. Thus, one can view tree boosting with
shrinkage as a form of monotone ill-posed regression on all possible (J-
terminal node) trees, with the lasso penalty (16.4) as a regularizer. We
return to this topic in Section 16.2.3.

The choice of no shrinkage [ν = 1 in equation (10.41)] is analogous to
forward-stepwise regression, and its more aggressive cousin best-subset se-
0.
lection, which penalizes the number of non zero coeﬃcients J(α) =
αk|
With a small fraction of dominant variables, best subset approaches often
work well. But with a moderate fraction of strong variables, it is well known
that subset selection can be excessively greedy (Copas, 1983), often yielding
poor results when compared to less aggressive strategies such as the lasso
or ridge regression. The dramatic improvements often seen when shrinkage
is used with boosting are yet another conﬁrmation of this approach.

k |

P

16.2.2 The “Bet on Sparsity” Principle

As shown in the previous section, boosting’s forward stagewise strategy
with shrinkage approximately minimizes the same loss function with a
lasso-style L1 penalty. The model is built up slowly, searching through
“model space” and adding shrunken basis functions derived from impor-
tant predictors. In contrast, the L2 penalty is computationally much easier
to deal with, as shown in Section 12.3.7. With the basis functions and L2
penalty chosen to match a particular positive-deﬁnite kernel, one can solve
the corresponding optimization problem without explicitly searching over
individual basis functions.

However, the sometimes superior performance of boosting over proce-
dures such as the support vector machine may be largely due to the im-
plicit use of the L1 versus L2 penalty. The shrinkage resulting from the

16.2 Boosting and Regularization Paths

611

L1 penalty is better suited to sparse situations, where there are few basis
functions with nonzero coeﬃcients (among all possible choices).

We can strengthen this argument through a simple example, taken from
Friedman et al. (2004). Suppose we have 10, 000 data points and our model
is a linear combination of a million trees. If the true population coeﬃcients
of these trees arose from a Gaussian distribution, then we know that in a
Bayesian sense the best predictor is ridge regression (Exercise 3.6). That is,
we should use an L2 rather than an L1 penalty when ﬁtting the coeﬃcients.
On the other hand, if there are only a small number (e.g., 1000) coeﬃcients
that are nonzero, the lasso (L1 penalty) will work better. We think of this
as a sparse scenario, while the ﬁrst case (Gaussian coeﬃcients) is dense.
Note however that in the dense scenario, although the L2 penalty is best,
neither method does very well since there is too little data from which to
estimate such a large number of nonzero coeﬃcients. This is the curse of
dimensionality taking its toll. In a sparse setting, we can potentially do
well with the L1 penalty, since the number of nonzero coeﬃcients is small.
The L2 penalty fails again.

In other words, use of the L1 penalty follows what we call the “bet on

sparsity” principle for high-dimensional problems:

Use a procedure that does well in sparse problems, since no pro-
cedure does well in dense problems.

These comments need some qualiﬁcation:

•

•

For any given application, the degree of sparseness/denseness depends
on the unknown true target function, and the chosen dictionary

.

T

The notion of sparse versus dense is relative to the size of the train-
ing data set and/or the noise-to-signal ratio (NSR). Larger training
sets allow us to estimate coeﬃcients with smaller standard errors.
Likewise in situations with small NSR, we can identify more nonzero
coeﬃcients with a given sample size than in situations where the NSR
is larger.

•

The size of the dictionary plays a role as well. Increasing the size of the
dictionary may lead to a sparser representation for our function, but
the search problem becomes more diﬃcult leading to higher variance.

Figure 16.2 illustrates these points in the context of linear models us-
ing simulation. We compare ridge regression and lasso, both for classiﬁ-
cation and regression problems. Each run has 50 observations with 300
independent Gaussian predictors. In the top row all 300 coeﬃcients are
nonzero, generated from a Gaussian distribution. In the middle row, only
10 are nonzero and generated from a Gaussian, and the last row has 30
non zero Gaussian coeﬃcients. For regression, standard Gaussian noise is

612

16. Ensemble Learning

Regression

Classification

Lasso/Gaussian

Ridge/Gaussian

Lasso/Gaussian

Ridge/Gaussian

i

d
e
n
a
p
x
E

l

r
o
r
r

i

E
n
o
i
t
c
d
e
r
P
d
e
r
a
u
q
S
e
g
a
t
n
e
c
r
e
P

0
0
1
1

.
.

8
8
0
0

.
.

6
6
0
0

.
.

4
4
0
0

.
.

2
2
0
0

.
.

0
0
0
0

.
.

0
0
.
.
1
1

8
8
.
.
0
0

6
6
.
.
0
0

4
4
.
.
0
0

2
2
.
.
0
0

0
0
.
.
0
0

0
0
.
.
1
1

8
8
.
.
0
0

6
6
.
.
0
0

4
4
.
.
0
0

2
2
.
.
0
0

0
0
.
.
0
0

0.1 0.2 0.3 0.4 0.5

0.1 0.2 0.3 0.4 0.5

Lasso/Subset 10

Ridge/Subset 10

0.1 0.2 0.3 0.4 0.5

0.1 0.2 0.3 0.4 0.5

Lasso/Subset 30

Ridge/Subset 30

i

d
e
n
a
p
x
E

l

r
o
r
r

l

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M
e
g
a
t
n
e
c
r
e
P

i

0
0
1
1

.
.

8
8
0
0

.
.

6
6
0
0

.
.

4
4
0
0

.
.

2
2
0
0

.
.

0
0
0
0

.
.

0
0
.
.
1
1

8
8
.
.
0
0

6
6
.
.
0
0

4
4
.
.
0
0

2
2
.
.
0
0

0
0
.
.
0
0

0
0
.
.
1
1

8
8
.
.
0
0

6
6
.
.
0
0

4
4
.
.
0
0

2
2
.
.
0
0

0
0
.
.
0
0

0.1 0.2 0.3 0.4 0.5

0.1 0.2 0.3 0.4 0.5

Lasso/Subset 10

Ridge/Subset 10

0.1 0.2 0.3 0.4 0.5

0.1 0.2 0.3 0.4 0.5

Lasso/Subset 30

Ridge/Subset 30

0.1 0.2 0.3 0.4 0.5

0.1 0.2 0.3 0.4 0.5

0.1 0.2 0.3 0.4 0.5

0.1 0.2 0.3 0.4 0.5

Noise−to−Signal Ratio

Noise−to−Signal Ratio

FIGURE 16.2. Simulations that show the superiority of the L1 (lasso) penalty
over L2 (ridge) in regression and classiﬁcation. Each run has 50 observations
with 300 independent Gaussian predictors. In the top row all 300 coeﬃcients are
nonzero, generated from a Gaussian distribution. In the middle row, only 10 are
nonzero, and the last row has 30 nonzero. Gaussian errors are added to the linear
predictor η(X) for the regression problems, and binary responses generated via the
inverse-logit transform for the classiﬁcation problems. Scaling of η(X) resulted in
the noise-to-signal ratios shown. Lasso is used in the left sub-columns, ridge in the
right. We report the optimal percentage of error explained on test data (relative
to the error of a constant model), displayed as boxplots over 20 realizations for
each combination. In the only situation where ridge beats lasso (top row), neither
do well.

 
 
 
 
 
 
 
16.2 Boosting and Regularization Paths

613

added to the linear predictor η(X) = X T β to produce a continuous re-
sponse. For classiﬁcation the linear predictor is transformed via the inverse-
logit to a probability, and a binary response is generated. Five diﬀer-
ent noise-to-signal ratios are presented, obtained by scaling η(X) prior
to generating the response. In both cases this is deﬁned to be NSR =
η(X))/Var(η(X)). Both the ridge regression and lasso coeﬃcient
Var(Y
paths were ﬁt using a series of 50 values of λ corresponding to a range of
df from 1 to 50 (see Chapter 3 for details). The models were evaluated on
a large test set (inﬁnite for Gaussian, 5000 for binary), and in each case the
value for λ was chosen to minimize the test-set error. We report percentage
variance explained for the regression problems, and percentage misclassiﬁ-
cation error explained for the classiﬁcation problems (relative to a baseline
error of 0.5). There are 20 simulation runs for each scenario.

|

Note that for the classiﬁcation problems, we are using squared-error loss
to ﬁt the binary response. Note also that we do not using the training
data to select λ, but rather are reporting the best possible behavior for
each method in the diﬀerent scenarios. The L2 penalty performs poorly
everywhere. The Lasso performs reasonably well in the only two situations
where it can (sparse coeﬃcients). As expected the performance gets worse
as the NSR increases (less so for classiﬁcation), and as the model becomes
denser. The diﬀerences are less marked for classiﬁcation than for regression.
These empirical results are supported by a large body of theoretical
results (Donoho and Johnstone, 1994; Donoho and Elad, 2003; Donoho,
2006b; Candes and Tao, 2007) that support the superiority of L1 estimation
in sparse settings.

16.2.3 Regularization Paths, Over-ﬁtting and Margins

It has often been observed that boosting “does not overﬁt,” or more as-
tutely is “slow to overﬁt.” Part of the explanation for this phenomenon was
made earlier for random forests — misclassiﬁcation error is less sensitive to
variance than is mean-squared error, and classiﬁcation is the major focus
in the boosting community. In this section we show that the regulariza-
tion paths of boosted models are “well behaved,” and that for certain loss
functions they have an appealing limiting form.

Figure 16.3 shows the coeﬃcient paths for lasso and inﬁnitesimal forward
stagewise (FS0) in a simulated regression setting. The data consists of a
dictionary of 1000 Gaussian variables, strongly correlated (ρ = 0.95) within
blocks of 20, but uncorrelated between blocks. The generating model has
nonzero coeﬃcients for 50 variables, one drawn from each block, and the
coeﬃcient values are drawn from a standard Gaussian. Finally, Gaussian
noise is added, with a noise-to-signal ratio of 0.72 (Exercise 16.1.) The
FS0 algorithm is a limiting form of algorithm 16.1, where the step size ε
is shrunk to zero (Section 3.8.1). The grouping of the variables is intended
to mimic the correlations of nearby trees, and with the forward-stagewise

614

16. Ensemble Learning

LASSO

Forward Stagewise

i

s
t
n
e
c
i
f
f
e
o
C
d
e
z
d
r
a
d
n
a
t
S

i

0
3

0
2

0
1

0

0
1
−

0
2
−

i

s
t
n
e
c
i
f
f
e
o
C
d
e
z
d
r
a
d
n
a
t
S

i

0
3

0
2

0
1

0

0
1
−

0
2
−

0.0

0.2

0.4

0.6

0.8

1.0

0.0

0.2

0.4

0.6

0.8

1.0

α(m)

α(

/

|

|

)

|

∞

|

α(m)

α(

/

|

|

)

|

∞

|

FIGURE 16.3. Comparison of lasso and inﬁnitesimal forward stagewise paths
on simulated regression data. The number of samples is 60 and the number of
variables is 1000. The forward-stagewise paths ﬂuctuate less than those of lasso
in the ﬁnal stages of the algorithms.

algorithm, this setup is intended as an idealized version of gradient boosting
with shrinkage. For both these algorithms, the coeﬃcient paths can be
computed exactly, since they are piecewise linear (see the LARS algorithm
in Section 3.8.1).

Here the coeﬃcient proﬁles are similar only in the early stages of the
paths. For the later stages, the forward stagewise paths tend to be mono-
tone and smoother, while those for the lasso ﬂuctuate widely. This is due
to the strong correlations among subsets of the variables —lasso suﬀers
somewhat from the multi-collinearity problem (Exercise 3.28).

The performance of the two models is rather similar (Figure 16.4), and
they achieve about the same minimum. In the later stages forward stagewise
takes longer to overﬁt, a likely consequence of the smoother paths.

Hastie et al. (2007) show that FS0 solves a monotone version of the lasso
problem for squared error loss. Let
be the augmented
T
dictionary obtained by including a negative copy of every basis element
Tk∈T a αkTk(x) with non-negative co-
in
0. In this expanded space, the lasso coeﬃcient paths are
eﬃcients αk ≥
positive, while those of FS0 are monotone nondecreasing.

. We consider models f (x) =

T ∪ {−T }

a =

P

T

The monotone lasso path is characterized by a diﬀerential equation

∂α
∂ℓ

= ρml(α(ℓ)),

(16.6)

 
 
16.2 Boosting and Regularization Paths

615

o
o
oo
oo
o
o

oo
o

oo
oo

r
o
r
r
E

d
e
r
a
u
q
S

n
a
e
M

5
5

0
5

5
4

0
4

5
3

0
3

5
2

Lasso
Forward Stagewise

o
o
ooo
oo
ooooo
oooo

o
oooooo
oo

ooooooooooo oooooooo oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
ooooooooo ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

oooooo
ooooooo
oo
ooooooooooooo

0

10

20

30

40

50

60

70

|α(m)|

FIGURE 16.4. Mean squared error for lasso and inﬁnitesimal forward stagewise
on the simulated data. Despite the diﬀerence in the coeﬃcient paths, the two
models perform similarly over the critical part of the regularization path. In the
right tail, lasso appears to overﬁt more rapidly.

with initial condition α(0) = 0, where ℓ is the L1 arc-length of the path
α(ℓ) (Exercise 16.2). The monotone lasso move direction (velocity vector)
ρml(α(ℓ)) decreases the loss at the optimal quadratic rate per unit increase
in the L1 arc-length of the path. Since ρml
k, ℓ, the solution
paths are monotone.

k (α(ℓ))

≥

∀

0

The lasso can similarly be characterized as the solution to a diﬀerential
equation as in (16.6), except that the move directions decrease the loss
optimally per unit increase in the L1 norm of the path. As a consequence,
they are not necessarily positive, and hence the lasso paths need not be
monotone.

In this augmented dictionary, restricting the coeﬃcients to be positive is
natural, since it avoids an obvious ambiguity. It also ties in more naturally
with tree boosting—we always ﬁnd trees positively correlated with the
current residual.

There have been suggestions that boosting performs well (for two-class
classiﬁcation) because it exhibits maximal-margin properties, much like the
support-vector machines of Chapters 4.5.2 and 12. Schapire et al. (1998)
k αkTk(x) as
deﬁne the normalized L1 margin of a ﬁtted model f (x) =

m(f ) = min

i

yif (xi)
K
αk|
k=1 |

.

P

(16.7)

.
1, +1
Here the minimum is taken over the training sample, and yi ∈ {−
}
Unlike the L2 margin (4.40) of support vector machines, the L1 margin
m(f ) measures the distance to the closest training point in L∞ units (max-
imum coordinate distance).

P

616

16. Ensemble Learning

i

n
g
r
a
M

1
.
0

0
.
0

1
.
0
−

2
.
0
−

3
.
0
−

r
o
r
r

E

t
s
e
T

8
2
.
0

7
2
.
0

6
2
.
0

5
2
.
0

0

2K

4K

6K

8K

10K

0

2K

4K

6K

8K

10K

Number of Trees

Number of Trees

FIGURE 16.5. The left panel shows the L1 margin m(f ) for the Adaboost clas-
siﬁer on the mixture data, as a function of the number of 4-node trees. The model
was ﬁt using the R package gbm, with a shrinkage factor of 0.02. After 10, 000
trees, m(f ) has settled down. Note that when the margin crosses zero, the training
error becomes zero. The right panel shows the test error, which is minimized at
240 trees. In this case, Adaboost overﬁts dramatically if run to convergence.

Schapire et al. (1998) prove that with separable data, Adaboost in-
creases m(f ) with each iteration, converging to a margin-symmetric so-
lution. R¨atsch and Warmuth (2002) prove the asymptotic convergence of
Adaboost with shrinkage to a L1-margin-maximizing solution. Rosset et
al. (2004a) consider regularized models of the form (16.2) for general loss
0, for particular loss functions the solution
functions. They show that as λ
converges to a margin-maximizing conﬁguration. In particular they show
this to be the case for the exponential loss of Adaboost, as well as binomial
deviance.

↓

Collecting together the results of this section, we reach the following

summary for boosted classiﬁers:

The sequence of boosted classiﬁers form an L1-regularized mono-
tone path to a margin-maximizing solution.

Of course the margin-maximizing end of the path can be a very poor, overﬁt
solution, as it is in the example in Figure 16.5. Early stopping amounts
to picking a point along the path, and should be done with the aid of a
validation dataset.

16.3 Learning Ensembles

The insights learned from the previous sections can be harnessed to produce
a more eﬀective and eﬃcient ensemble model. Again we consider functions

 
of the form

f (x) = α0 +

αkTk(x),

(16.8)

16.3 Learning Ensembles

617

XTk∈T

T

is a dictionary of basis functions, typically trees. For gradient
where
boosting and random forests,
is very large, and it is quite typical for the
ﬁnal model to involve many thousands of trees. In the previous section we
argue that gradient boosting with shrinkage ﬁts an L1 regularized monotone
path in this space of trees.

|T |

Friedman and Popescu (2003) propose a hybrid approach which breaks

this process down into two stages:

•

•

A ﬁnite dictionary
is induced from the training data;

TL =

T1(x), T2(x), . . . , TM (x)
{

of basis functions

}

A family of functions fλ(x) is built by ﬁtting a lasso path in this
dictionary:

α(λ) = arg min

α

N

i=1
X

M

L[yi, α0 +

αmTm(xi)] + λ

m=1
X

M

m=1
X

.

αm|

|

(16.9)

In its simplest form this model could be seen as a way of post-processing
boosting or random forests, taking for
TL the collection of trees produced
by the gradient boosting or random forest algorithms. By ﬁtting the lasso
path to these trees, we would typically use a much reduced set, which would
save in computations and storage for future predictions. In the next section
we describe modiﬁcations of this prescription that reduce the correlations in
TL, and improve the performance of the lasso post processor.
the ensemble
As an initial illustration, we apply this procedure to a random forest

ensemble grown on the spam data.

Figure 16.6 shows that a lasso post-processing oﬀers modest improve-
ment over the random forest (blue curve), and reduces the forest to about
40 trees, rather than the original 1000. The post-processed performance
matches that of gradient boosting. The orange curves represent a modiﬁed
version of random forests, designed to reduce the correlations between trees
even more. Here a random sub-sample (without replacement) of 5% of the
training sample is used to grow each tree, and the trees are restricted to be
shallow (about six terminal nodes). The post-processing oﬀers more dra-
matic improvements here, and the training costs are reduced by a factor
of about 100. However, the performance of the post-processed model falls
somewhat short of the blue curves.

16.3.1 Learning a Good Ensemble

TL will perform well with post-processing. In terms of
Not all ensembles
basis functions, we want a collection that covers the space well in places

Spam Data

Random Forest
Random Forest (5%, 6)
Gradient Boost (5 node)

618

16. Ensemble Learning

r
o
r
r

E

t
s
e
T

9
0
.
0

8
0
.
0

7
0
.
0

6
0
.
0

5
0
.
0

4
0
.
0

0

100

200

300

400

500

Number of Trees

FIGURE 16.6. Application of the lasso post-processing (16.9) to the spam data.
The horizontal blue line is the test error of a random forest ﬁt to the spam data,
using 1000 trees grown to maximum depth (with m = 7; see Algorithm 15.1).
The jagged blue curve is the test error after post-processing the ﬁrst 500 trees
using the lasso, as a function of the number of trees with nonzero coeﬃcients.
The orange curve/line use a modiﬁed form of random forest, where a random
draw of 5% of the data are used to grow each tree, and the trees are forced to
be shallow (typically six terminal nodes). Here the post-processing oﬀers much
greater improvement over the random forest that generated the ensemble.

where they are needed, and are suﬃciently diﬀerent from each other for
the post-processor to be eﬀective.

Friedman and Popescu (2003) gain insights from numerical quadrature
and importance sampling. They view the unknown function as an integral

f (x) =

β(γ)b(x; γ)dγ,

(16.10)

Z

∈

where γ
Γ indexes the basis functions b(x; γ). For example, if the basis
functions are trees, then γ indexes the splitting variables, the split-points
and the values in the terminal nodes. Numerical quadrature amounts to
Γ and corresponding weights
ﬁnding a set of M evaluation points γm ∈
M
αm so that fM (x) = α0 +
m=1 αmb(x; γm) approximates f (x) well over
the domain of x. Importance sampling amounts to sampling γ at random,
but giving more weight to relevant regions of the space Γ. Friedman and
Popescu (2003) suggest a measure of (lack of) relevance that uses the loss
function (16.9):

P

 
•

•

16.3 Learning Ensembles

619

L(yi, c0 + c1b(xi; γ)),

(16.11)

Q(γ) = min
c0,c1

N

i=1
X

evaluated on the training data.

If a single basis function were to be selected (e.g., a tree), it would be
the global minimizer γ∗ = arg minγ∈Γ Q(γ). Introducing randomness in the
selection of γ would necessarily produce less optimal values with Q(γ)
≥
Q(γ∗). They propose a natural measure of the characteristic width σ of the
sampling scheme

,

S

σ = ES [Q(γ)

Q(γ∗)].

(16.12)

−
σ too narrow suggests too many of the b(x; γm) look alike, and similar
to b(x; γ∗);

σ too wide implies a large spread in the b(x; γm), but possibly con-
sisting of many irrelevant cases.

Friedman and Popescu (2003) use sub-sampling as a mechanism for intro-
ducing randomness, leading to their ensemble-generation algorithm 16.2.

Algorithm 16.2 ISLE Ensemble Generation.

1. f0(x) = arg minc

N
i=1 L(yi, c)

P
2. For m = 1 to M do

(a) γm = arg minγ

i∈Sm(η) L(yi, fm−1(xi) + b(xi; γ))

(b) fm(x) = fm−1(x) + νb(x; γm)

P

3.

TISLE =

b(x; γ1), b(x; γ2), . . . , b(x; γM )
{

.
}

≤

η (η

Sm(η) refers to a subsample of N

1
2 , and for large N picking η

(0, 1]) of the training obser-
·
vations, typically without replacement. Their simulations suggest picking
1/√N . Reducing η increases the
η
randomness, and hence the width σ. The parameter ν
[0, 1] introduces
memory into the randomization process; the larger ν, the more the pro-
cedure avoids b(x; γ) similar to those found before. A number of familiar
randomization schemes are special cases of Algorithm 16.2:

∼

∈

∈

Bagging has η = 1, but samples with replacement, and has ν = 0. Fried-
man and Hall (2007) argue that sampling without replacement with
η = 1/2 is equivalent to sampling with replacement with η = 1, and
the former is much more eﬃcient.

620

16. Ensemble Learning

Random forest sampling is similar, with more randomness introduced by
the selection of the splitting variable. Reducing η < 1/2 in algo-
rithm 16.2 has a similar eﬀect to reducing m in random forests, but
does not suﬀer from the potential biases discussed in Section 15.4.2.

Gradient boosting with shrinkage (10.41) uses η = 1, but typically does

not produce suﬃcient width σ.

Stochastic gradient boosting (Friedman, 1999) follows the recipe exactly.

1
2 , and call their combined
The authors recommend values ν = 0.1 and η
procedure (ensemble generation and post processing) Importance sampled
learning ensemble (ISLE).

≤

Figure 16.7 shows the performance of an ISLE on the spam data. It does

Spam Data

Gradient Boosting (5 Node)
Lasso Post−processed

r
o
r
r

E

t
s
e
T

0
6
0
.
0

5
5
0
.
0

0
5
0
.
0

5
4
0
.
0

0
4
0
.
0

0

500

1000

1500

2000

2500

Number of Trees

FIGURE 16.7. Importance sampling learning ensemble (ISLE) ﬁt to the spam
data. Here we used η = 1/2, ν = 0.05, and trees with ﬁve terminal nodes. The
lasso post-processed ensemble does not improve the prediction error in this case,
but it reduces the number of trees by a factor of ﬁve.

not improve the predictive performance, but is able to produce a more
parsimonious model. Note that in practice the post-processing includes
the selection of the regularization parameter λ in (16.9), which would be

 
16.3 Learning Ensembles

621

chosen by cross-validation. Here we simply demonstrate the eﬀects of post-
processing by showing the entire path on the test data.

Figure 16.8 shows various ISLEs on a regression example. The generating

GBM (1, 0.01)
GBM (0.1, 0.01)
ISLE  GB
ISLE RF
Random Forest

5

.

3

0

.

3

5

.

2

0

.

2

5
.
1

0
.
1

r
o
r
r

E
d
e
r
a
u
q
S
n
a
e
M

0

500

1000

1500

2000

2500

Number of Trees

FIGURE 16.8. Demonstration of ensemble methods on a regression simulation
example. The notation GBM (0.1, 0.01) refers to a gradient boosted model, with
parameters (η, ν). We report mean-squared error from the true (known) function.
Note that the sub-sampled GBM model (green) outperforms the full GBM model
(orange). The lasso post-processed version achieves similar error. The random
forest is outperformed by its post-processed version, but both fall short of the
other models.

function is

f (X) = 10

e−2X 2

j +

5

·

j=1
Y

Xj,

35

j=6
X

(16.13)

∼

U [0, 1]100 (the last 65 elements are noise variables). The re-
where X
N (0, σ2); we chose σ = 1.3 resulting in a
sponse Y = f (X) + ε where ε
signal-to-noise ratio of approximately 2. We used a training sample of size
1000, and estimated the mean squared error E( ˆf (X)
f (X))2 by averaging
over a test set of 500 samples. The sub-sampled GBM curve (light blue)
is an instance of stochastic gradient boosting (Friedman, 1999) discussed in
Section 10.12, and it outperforms gradient boosting on this example.

∼

−

 
 
622

16. Ensemble Learning

16.3.2 Rule Ensembles

Here we describe a modiﬁcation of the tree-ensemble method that focuses
on individual rules (Friedman and Popescu, 2003). We encountered rules
in Section 9.3 in the discussion of the PRIM method. The idea is to enlarge
an ensemble of trees by constructing a set of rules from each of the trees
in the collection.

0

X1 < 2.1

X1 ≥ 2.1

1

2

X3 ∈ {S}

X3 ∈ {M, L}

3

4

X7 < 4.5

X7 ≥ 4.5

5

6

FIGURE 16.9. A typical tree in an ensemble, from which rules can be derived.

Figure 16.9 depicts a small tree, with numbered nodes. The following

rules can be derived from this tree:

R1(X) = I(X1 < 2.1)
2.1)
R2(X) = I(X1
2.1)
R3(X) = I(X1
2.1)
R4(X) = I(X1
2.1)
R5(X) = I(X1
2.1)
R6(X) = I(X1

≥
≥
≥
≥
≥

I(X3
I(X3
I(X3
I(X3

·
·
·
·

∈ {
∈ {
∈ {
∈ {

)
S
}
M, L
)
S
)
S

}
}

·
·

(16.14)

)
}
I(X7 < 4.5)
4.5)
I(X7

≥

A linear expansion in rules 1, 4, 5 and 6 is equivalent to the tree itself
(Exercise 16.3); hence (16.14) is an over-complete basis for the tree.

For each tree Tm in an ensemble

, we can construct its mini-ensemble

m
RULE, and then combine them all to form a larger ensemble

of rules

T

T

M

TRULE =

T

m
RULE.

(16.15)

m=1
[
This is then treated like any other ensemble, and post-processed via the
lasso or similar regularized procedure.

There are several advantages to this approach of deriving rules from the

more complex trees:

•

The space of models is enlarged, and can lead to improved perfor-
mance.

16.3 Learning Ensembles

623

3
.
1

2
.
1

1
.
1

0
.
1

9
.
0

r
o
r
r

E
d
e
r
a
u
q
S
n
a
e
M

Rules

Rules + Linear

FIGURE 16.10. Mean squared error for rule ensembles, using 20 realizations
of the simulation example (16.13).

•

•

Rules are easier to interpret than trees, so there is the potential for
a simpliﬁed model.

It is often natural to augment
RULE by including each variable Xj
separately as well, thus allowing the ensemble to model linear func-
tions well.

T

Friedman and Popescu (2008) demonstrate the power of this procedure on a
number of illustrative examples, including the simulation example (16.13).
Figure 16.10 shows boxplots of the mean-squared error from the true model
for twenty realizations from this model. The models were all ﬁt using the
Rulefit software, available on the ESL homepage3, which runs in an auto-
matic mode.

On the same training set as used in Figure 16.8, the rule based model
achieved a mean-squared error of 1.06. Although slightly worse than the
best achieved in that ﬁgure, the results are not comparable because cross-
validation was used here to select the ﬁnal model.

Bibliographic Notes

As noted in the introduction, many of the new methods in machine learning
have been dubbed “ensemble” methods. These include neural networks
boosting, bagging and random forests; Dietterich (2000a) gives a survey of
tree-based ensemble methods. Neural networks (Chapter 11) are perhaps
more deserving of the name, since they simultaneously learn the parameters

3ESL homepage: www-stat.stanford.edu/ElemStatLearn

 
 
624

16. Ensemble Learning

of the hidden units (basis functions), along with how to combine them.
Bishop (2006) discusses neural networks in some detail, along with the
Bayesian perspective (MacKay, 1992; Neal, 1996). Support vector machines
(Chapter 12) can also be regarded as an ensemble method; they perform
L2 regularized model ﬁtting in high-dimensional feature spaces. Boosting
and lasso exploit sparsity through L1 regularization to overcome the high-
dimensionality, while SVMs rely on the “kernel trick” characteristic of L2
regularization.

C5.0 (Quinlan, 2004) is a commercial tree and rule generation package,

with some goals in common with Rulefit.

There is a vast and varied literature often referred to as “combining clas-
siﬁers” which abounds in ad-hoc schemes for mixing methods of diﬀerent
types to achieve better performance. For a principled approach, see Kittler
et al. (1998).

Exercises

Ex. 16.1 Describe exactly how to generate the block correlated data used
in the simulation in Section 16.2.3.

IRp be a piecewise-diﬀerentiable and continuous coef-
Ex. 16.2 Let α(t)
ﬁcient proﬁle, with α(0) = 0. The L1 arc-length of α from time 0 to t is
deﬁned by

∈

t

Λ(t) =

˙α(t)

|1dt.

0 |

Z

(16.16)

Show that Λ(t)

α(t)

|1, with equality iﬀ α(t) is monotone.

≥ |

Ex. 16.3 Show that ﬁtting a linear regression model using rules 1, 4, 5 and
6 in equation (16.14) gives the same ﬁt as the regression tree corresponding
to this tree. Show the same is true for classiﬁcation, if a logistic regression
model is ﬁt.

Ex. 16.4 Program and run the simulation study described in Figure 16.2.

17
Undirected Graphical Models

This is page 625
Printer: Opaque this

17.1

Introduction

A graph consists of a set of vertices (nodes), along with a set of edges join-
ing some pairs of the vertices. In graphical models, each vertex represents
a random variable, and the graph gives a visual way of understanding the
joint distribution of the entire set of random variables. They can be use-
ful for either unsupervised or supervised learning. In an undirected graph,
the edges have no directional arrows. We restrict our discussion to undi-
rected graphical models, also known as Markov random ﬁelds or Markov
networks. In these graphs, the absence of an edge between two vertices has
a special meaning: the corresponding random variables are conditionally
independent, given the other variables.

Figure 17.1 shows an example of a graphical model for a ﬂow-cytometry
dataset with p = 11 proteins measured on N = 7466 cells, from Sachs
et al. (2005). Each vertex in the graph corresponds to the real-valued ex-
pression level of a protein. The network structure was estimated assuming
a multivariate Gaussian distribution, using the graphical lasso procedure
discussed later in this chapter.

Sparse graphs have a relatively small number of edges, and are convenient
for interpretation. They are useful in a variety of domains, including ge-
nomics and proteomics, where they provide rough models of cell pathways.
Much work has been done in deﬁning and understanding the structure of
graphical models; see the Bibliographic Notes for references.

626

17. Undirected Graphical Models

Raf

Mek

Jnk

Plcg

PIP2

P38

PKC

PIP3

PKA

Erk

Akt

FIGURE 17.1. Example of a sparse undirected graph, estimated from a ﬂow
cytometry dataset, with p = 11 proteins measured on N = 7466 cells. The net-
work structure was estimated using the graphical lasso procedure discussed in this
chapter.

As we will see, the edges in a graph are parametrized by values or po-
tentials that encode the strength of the conditional dependence between
the random variables at the corresponding vertices. The main challenges in
working with graphical models are model selection (choosing the structure
of the graph), estimation of the edge parameters from data, and compu-
tation of marginal vertex probabilities and expectations, from their joint
distribution. The last two tasks are sometimes called learning and inference
in the computer science literature.

We do not attempt a comprehensive treatment of this interesting area.
Instead, we introduce some basic concepts, and then discuss a few sim-
ple methods for estimation of the parameters and structure of undirected
graphical models; methods that relate to the techniques already discussed
in this book. The estimation approaches that we present for continuous
and discrete-valued vertices are diﬀerent, so we treat them separately. Sec-
tions 17.3.1 and 17.3.2 may be of particular interest, as they describe new,
regression-based procedures for estimating graphical models.

There is a large and active literature on directed graphical models or
Bayesian networks; these are graphical models in which the edges have
directional arrows (but no directed cycles). Directed graphical models rep-
resent probability distributions that can be factored into products of condi-
tional distributions, and have the potential for causal interpretations. We
refer the reader to Wasserman (2004) for a brief overview of both undi-
rected and directed graphs; the next section follows closely his Chapter 18.

17.2 Markov Graphs and Their Properties

627

Y

(a)

Z

Z

W

X

Y

X

Y

X

W

Z

(b)

X

Y

Z

W

(c)

(d)

FIGURE 17.2. Examples of undirected graphical models or Markov networks.
Each node or vertex represents a random variable, and the lack of an edge between
two nodes indicates conditional independence. For example, in graph (a), X and
Z are conditionally independent, given Y . In graph (b), Z is independent of each
of X, Y , and W .

A longer list of useful references is given in the Bibliographic Notes on
page 645.

17.2 Markov Graphs and Their Properties

In this section we discuss the basic properties of graphs as models for the
joint distribution of a set of random variables. We defer discussion of (a)
parametrization and estimation of the edge parameters from data, and (b)
estimation of the topology of a graph, to later sections.

G

Figure 17.2 shows four examples of undirected graphs. A graph

consists
of a pair (V, E), where V is a set of vertices and E the set of edges (deﬁned
by pairs of vertices). Two vertices X and Y are called adjacent if there
Y . A path X1, X2, . . . , Xn
is a edge joining them; this is denoted by X
Xi for i = 2, . . . , n. A
is a set of vertices that are joined, that is Xi−1 ∼
complete graph is a graph with every pair of vertices joined by an edge.
A subgraph U
V is a subset of vertices together with their edges. For
example, (X, Y, Z) in Figure 17.2(a) form a path but not a complete graph.
whose vertex set V represents a set of
G
random variables having joint distribution P . In a Markov graph
, the
absence of an edge implies that the corresponding random variables are
conditionally independent given the variables at the other vertices. This is
expressed with the following notation:

Suppose that we have a graph

∼

∈

G

628

17. Undirected Graphical Models

No edge joining X and Y

X

Y

|

⊥

rest

⇐⇒

(17.1)

G

where “rest” refers to all of the other vertices in the graph. For example
in Figure 17.2(a) X
Y . These are known as the pairwise Markov
.
independencies of

⊥

Z

|

If A, B and C are subgraphs, then C is said to separate A and B if every
path between A and B intersects a node in C. For example, Y separates
X and Z in Figures 17.2(a) and (d), and Z separates Y and W in (d). In
Figure 17.2(b) Z is not connected to X, Y, W so we say that the two sets
separates
are separated by the empty set. In Figure 17.2(c), C =
Y and W .

X, Z
{

}

Separators have the nice property that they break the graph into con-
with sub-

ditionally independent pieces. Speciﬁcally, in a Markov graph
graphs A, B and C,

G

if C separates A and B then A

C.

B

|

⊥

(17.2)

G

These are known as the global Markov properties of
. It turns out that the
pairwise and global Markov properties of a graph are equivalent (for graphs
with positive distributions). That is, the set of graphs with associated prob-
ability distributions that satisfy the pairwise Markov independencies and
global Markov assumptions are the same. This result is useful for inferring
global independence relations from simple pairwise properties. For example
in Figure 17.2(d) X
since it is a Markov graph and there is no
link joining X and Z. But Y also separates X from Z and W and hence by
the global Markov assumption we conclude that X
Y .
W
Similarly we have Y

Y and X

Y, W

Z.

W

|{

⊥

⊥

⊥

Z

Z

}

|

|

The global Markov property allows us to decompose graphs into smaller
more manageable pieces and thus leads to essential simpliﬁcations in com-
putation and interpretation. For this purpose we separate the graph into
cliques. A clique is a complete subgraph— a set of vertices that are all
adjacent to one another; it is called maximal if it is a clique and no other
vertices can be added to it and still yield a clique. The maximal cliques for
the graphs of Figure 17.2 are

⊥

|

(a)

(b)

X, Y
{

,
}

Y, Z
{

,
}

X, Y, W
{

,
}

Z
{

,
}

(c)

X, Y
{

,
}

Y, Z
{

,
}

Z, W
{

,
}

X, W
{

, and
}

(d)

X, Y
{

,
}

Y, Z
{

,
}

Z, W
{

.
}

Although the following applies to both continuous and discrete distri-
butions, much of the development has been for the latter. A probability
density function f over a Markov graph

can be can represented as

G

17.2 Markov Graphs and Their Properties

629

1
Z

f (x) =

ψC(xC)

(17.3)

C

YC∈C
is the set of maximal cliques, and the positive functions ψC(

where
) are
called clique potentials. These are not in general density functions1, but
rather are aﬃnities that capture the dependence in XC by scoring certain
instances xC higher than others. The quantity

·

Z =

ψC(xC)

(17.4)

Xx∈X YC∈C

is the normalizing constant, also known as the partition function. Alterna-
tively, the representation (17.3) implies a graph with independence prop-
erties deﬁned by the cliques in the product. This result holds for Markov
networks
with positive distributions, and is known as the Hammersley-
Cliﬀord theorem (Hammersley and Cliﬀord, 1971; Cliﬀord, 1990).

G

Many of the methods for estimation and computation on graphs ﬁrst de-
compose the graph into its maximal cliques. Relevant quantities are com-
puted in the individual cliques and then accumulated across the entire
graph. A prominent example is the join tree or junction tree algorithm for
computing marginal and low order probabilities from the joint distribution
on a graph. Details can be found in Pearl (1986), Lauritzen and Spiegel-
halter (1988), Pearl (1988), Shenoy and Shafer (1988), Jensen et al. (1990),
or Koller and Friedman (2007).

Y

X

Z

FIGURE 17.3. A complete graph does not uniquely specify the higher-order
dependence structure in the joint distribution of the variables.

A graphical model does not always uniquely specify the higher-order
dependence structure of a joint probability distribution. Consider the com-
plete three-node graph in Figure 17.3. It could represent the dependence
structure of either of the following distributions:

f (2)(x, y, z) = 1
f (3)(x, y, z) = 1

Z ψ(x, y)ψ(x, z)ψ(y, z);
Z ψ(x, y, z).

(17.5)

The ﬁrst speciﬁes only second order dependence (and can be represented
with fewer parameters). Graphical models for discrete data are a special

1If the cliques are separated, then the potentials can be densities, but this is in general

not the case.

630

17. Undirected Graphical Models

case of loglinear models for multiway contingency tables (Bishop et al.,
1975, e.g.); in that language f (2) is referred to as the “no second-order
interaction” model.

For the remainder of this chapter we focus on pairwise Markov graphs
(Koller and Friedman, 2007). Here there is a potential function for each
edge (pair of variables as in f (2) above), and at most second–order interac-
tions are represented. These are more parsimonious in terms of parameters,
easier to work with, and give the minimal complexity implied by the graph
structure. The models for both continuous and discrete data are functions
of only the pairwise marginal distributions of the variables represented in
the edge set.

17.3 Undirected Graphical Models for Continuous

Variables

Here we consider Markov networks where all the variables are continuous.
The Gaussian distribution is almost always used for such graphical models,
because of its convenient analytical properties. We assume that the observa-
tions have a multivariate Gaussian distribution with mean µ and covariance
matrix Σ. Since the Gaussian distribution represents at most second-order
relationships, it automatically encodes a pairwise Markov graph. The graph
in Figure 17.1 is an example of a Gaussian graphical model.

The Gaussian distribution has the property that all conditional distri-
butions are also Gaussian. The inverse covariance matrix Σ−1 contains
information about the partial covariances between the variables; that is,
the covariances between pairs i and j, conditioned on all other variables.
In particular, if the ijth component of Θ = Σ−1 is zero, then variables i and
j are conditionally independent, given the other variables (Exercise 17.3).
It is instructive to examine the conditional distribution of one variable
versus the rest, where the role of Θ is explicit. Suppose we partition X =
(Z, Y ) where Z = (X1, . . . , Xp−1) consists of the ﬁrst p
1 variables and
Y = Xp is the last. Then we have the conditional distribution of Y give Z
(Mardia et al., 1979, e.g.)

−

Z = z

Y

|

∼

N

µY + (z

µZ)T Σ−1

ZZσZY , σY Y −

−

ZY Σ−1
σT

ZZ σZY

,

(17.6)

(cid:0)
where we have partitioned Σ as

(cid:1)

Σ =

ΣZZ σZY
σT
ZY

σY Y (cid:19)

(cid:18)

.

(17.7)

The conditional mean in (17.6) has exactly the same form as the pop-
ulation multiple linear regression of Y on Z, with regression coeﬃcient
β = Σ−1
ZZσZY [see (2.16) on page 19]. If we partition Θ in the same way,
since ΣΘ = I standard formulas for partitioned inverses give

17.3 Undirected Graphical Models for Continuous Variables

631

where 1/θY Y = σY Y −

θZY =

θY Y ·

−

Σ−1

ZZσZY ,

ZY Σ−1
σT

ZZ σZY > 0. Hence

We have learned two things here:

=

−

β = Σ−1

ZZ σZY
θZY /θY Y .

(17.8)

(17.9)

•

The dependence of Y on Z in (17.6) is in the mean term alone. Here
we see explicitly that zero elements in β and hence θZY mean that
the corresponding elements of Z are conditionally independent of Y ,
given the rest.

•

We can learn about this dependence structure through multiple linear
regression.

Thus Θ captures all the second-order information (both structural and
quantitative) needed to describe the conditional distribution of each node
given the rest, and is the so-called “natural” parameter for the Gaussian
graphical model2.

Another (diﬀerent) kind of graphical model is the covariance graph or rel-
evance network, in which vertices are connected by bidirectional edges if the
covariance (rather than the partial covariance) between the corresponding
variables is nonzero. These are popular in genomics, see especially Butte
et al. (2000). The negative log-likelihood from these models is not convex,
making the computations more challenging (Chaudhuri et al., 2007).

17.3.1 Estimation of the Parameters when the Graph

Structure is Known

Given some realizations of X, we would like to estimate the parameters
of an undirected graph that approximates their joint distribution. Suppose
ﬁrst that the graph is complete (fully connected). We assume that we have
N multivariate normal realizations xi, i = 1, . . . , N with population mean
µ and covariance Σ. Let

S =

1
N

N

i=1
X

(xi −

¯x)(xi −

¯x)T

(17.10)

be the empirical covariance matrix, with ¯x the sample mean vector. Ignoring
constants, the log-likelihood of the data can be written as

2The distribution arising from a Gaussian graphical model is a Wishart distribution.
This is a member of the exponential family, with canonical or “natural” parameter
Θ = Σ−1. Indeed, the partially maximized log-likelihood (17.11) is (up to constants)
the Wishart log-likelihood.

632

17. Undirected Graphical Models

ℓ(Θ) = log det Θ

trace(SΘ).

−

(17.11)

In (17.11) we have partially maximized with respect to the mean parameter
ℓ(Θ) is a convex function of Θ. It is easy to show that
µ. The quantity
the maximum likelihood estimate of Σ is simply S.

−

Now to make the graph more useful (especially in high-dimensional set-
tings) let’s assume that some of the edges are missing; for example, the
edge between PIP3 and Erk is one of several missing in Figure 17.1. As we
have seen, for the Gaussian distribution this implies that the correspond-
ing entries of Θ = Σ−1 are zero. Hence we now would like to maximize
(17.11) under the constraints that some pre-deﬁned subset of the parame-
ters are zero. This is an equality-constrained convex optimization problem,
and a number of methods have been proposed for solving it, in particular
the iterative proportional ﬁtting procedure (Speed and Kiiveri, 1986). This
and other methods are summarized for example in Whittaker (1990) and
Lauritzen (1996). These methods exploit the simpliﬁcations that arise from
decomposing the graph into its maximal cliques, as described in the previ-
ous section. Here we outline a simple alternate approach, that exploits the
sparsity in a diﬀerent way. The fruits of this approach will become apparent
later when we discuss the problem of estimation of the graph structure.

The idea is based on linear regression, as inspired by (17.6) and (17.9).
In particular, suppose that we want to estimate the edge parameters θij for
the vertices that are joined to a given vertex i, restricting those that are not
joined to be zero. Then it would seem that the linear regression of the node
i values on the other relevant vertices might provide a reasonable estimate.
But this ignores the dependence structure among the predictors in this
regression. It turns out that if instead we use our current (model-based)
estimate of the cross-product matrix of the predictors when we perform
our regressions, this gives the correct solutions and solves the constrained
maximum-likelihood problem exactly. We now give details.

To constrain the log-likelihood (17.11), we add Lagrange constants for

all missing edges

ℓC(Θ) = log det Θ

trace(SΘ)

−

−

X(j,k)6∈E

γjkθjk.

(17.12)

The gradient equation for maximizing (17.12) can be written as

Θ−1

S

Γ = 0,

(17.13)

−
using the fact that the derivative of log det Θ equals Θ−1 (Boyd and Van-
denberghe, 2004, for example, page 641). Γ is a matrix of Lagrange param-
eters with nonzero values for all pairs with edges absent.

−

We will show how we can use regression to solve for Θ and its inverse
W = Θ−1 one row and column at a time. For simplicity let’s focus on the
last row and column. Then the upper right block of equation (17.13) can
be written as

17.3 Undirected Graphical Models for Continuous Variables

633

s12 −
Here we have partitioned the matrices into two parts as in (17.7): part 1
being the ﬁrst p
1 rows and columns, and part 2 the pth row and column.
With W and its inverse Θ partitioned in a similar fashion, we have

w12 −

γ12 = 0.

(17.14)

−

W11 w12
wT
12 w22(cid:19) (cid:18)

Θ11
θT
12

(cid:18)

θ12
θ22(cid:19)

=

I
0T

(cid:18)

.

0
1
(cid:19)

This implies

w12 =

W11θ12/θ22

−
= W11β

(17.15)

(17.16)

(17.17)

where β =
gives

−

θ12/θ22 as in (17.9). Now substituting (17.17) into (17.14)

W11β

These can be interpreted as the p

s12 −
1 estimating equations for the con-
−
strained regression of Xp on the other predictors, except that the observed
mean cross-products matrix S11 is replaced by W11, the current estimated
covariance matrix from the model.

γ12 = 0.

(17.18)

−

Now we can solve (17.18) by simple subset regression. Suppose there are
q nonzero elements in γ12—i.e., p
q edges constrained to be zero. These
q rows carry no information and can be removed. Furthermore we can
q zero elements, yielding the reduced

p
p
reduce β to β∗ by removing its p
q

q system of equations

−
−

−

−

×

W∗

11β∗

−

s∗
12 = 0,

(17.19)

with solution ˆβ∗ = W∗
11

q zeros to give ˆβ.
Although it appears from (17.16) that we only recover the elements θ12

12. This is padded with p

−1s∗

−

up to a scale factor 1/θ22, it is easy to show that

1
θ22

= w22 −

wT

12β

(17.20)

(using partitioned inverse formulas). Also w22 = s22, since the diagonal of
Γ in (17.13) is zero.

This leads to the simple iterative procedure given in Algorithm 17.1 for
estimating both ˆW and its inverse ˆΘ, subject to the constraints of the
missing edges.

Note that this algorithm makes conceptual sense. The graph estimation
problem is not p separate regression problems, but rather p coupled prob-
lems. The use of the common W in step (b), in place of the observed
cross-products matrix, couples the problems together in the appropriate
fashion. Surprisingly, we were not able to ﬁnd this procedure in the lit-
erature. However it is related to the covariance selection procedures of

634

17. Undirected Graphical Models

Algorithm 17.1 A Modiﬁed Regression Algorithm for Estimation of an
Undirected Gaussian Graphical Model with Known Structure.

1. Initialize W = S.

2. Repeat for j = 1, 2, . . . , p until convergence:

(a) Partition the matrix W into part 1: all but the jth row and

column, and part 2: the jth row and column.

(b) Solve W∗

11β∗

s∗
12 = 0 for the unconstrained edge parameters
β∗, using the reduced system of equations as in (17.19). Obtain
ˆβ by padding ˆβ∗ with zeros in the appropriate positions.

−

(c) Update w12 = W11 ˆβ

3. In the ﬁnal cycle (for each j) solve for ˆθ12 =

s22 −

wT
12

ˆβ.

ˆβ

·

−

ˆθ22, with 1/ˆθ22 =

X3

X2

X4

X1

S = 

10
1
5
4





1
10
2
6

5
2
10
3

4
6
3
10







FIGURE 17.4. A simple graph for illustration, along with the empirical covari-
ance matrix.

Dempster (1972), and is similar in ﬂavor to the iterative conditional ﬁtting
procedure for covariance graphs, proposed by Chaudhuri et al. (2007).

Here is a little example, borrowed from Whittaker (1990). Suppose that
our model is as depicted in Figure 17.4, along with its empirical covariance
matrix S. We apply algorithm (17.1) to this problem; for example, in the
modiﬁed regression for variable 1 in step (b), variable 3 is left out. The
procedure quickly converged to the solutions:

10.00
1.00
1.31
4.00

1.00
10.00
2.00
0.87

1.31
2.00
10.00
3.00

4.00
0.87
3.00
10.00

, ˆΣ−1 = 








0.12
0.01
−
0.00
0.05

−

0.01
−
0.11
0.02
−
0.00

0.00
0.02
−
0.11
0.03

−

0.05
−
0.00
0.03
−
0.13

.






ˆΣ = 



Note the zeroes in ˆΣ−1, corresponding to the missing edges (1,3) and (2,4).
Note also that the corresponding elements in ˆΣ are the only elements dif-
ferent from S. The estimation of ˆΣ is an example of what is sometimes
called the positive deﬁnite “completion” of S.

17.3 Undirected Graphical Models for Continuous Variables

635

17.3.2 Estimation of the Graph Structure

In most cases we do not know which edges to omit from our graph, and
so would like to try to discover this from the data itself. In recent years a
number of authors have proposed the use of L1 (lasso) regularization for
this purpose.

Meinshausen and B¨uhlmann (2006) take a simple approach to the prob-
lem: rather than trying to fully estimate Σ or Θ = Σ−1, they only estimate
which components of θij are nonzero. To do this, they ﬁt a lasso regression
using each variable as the response and the others as predictors. The com-
ponent θij is then estimated to be nonzero if either the estimated coeﬃcient
of variable i on j is nonzero, or the estimated coeﬃcient of variable j on
i is nonzero (alternatively they use an and rule). They show that asymp-
totically this procedure consistently estimates the set of nonzero elements
of Θ.

We can take a more systematic approach with the lasso penalty, following
the development of the previous section. Consider maximizing the penalized
log-likelihood

log det Θ

trace(SΘ)

λ

Θ

||1,

||

−

−

(17.21)

Θ

||

where
||1 is the L1 norm—the sum of the absolute values of the elements
of Σ−1, and we have ignored constants. The negative of this penalized
likelihood is a convex function of Θ.

It turns out that one can adapt the lasso to give the exact maximizer of
the penalized log-likelihood. In particular, we simply replace the modiﬁed
regression step (b) in Algorithm 17.1 by a modiﬁed lasso step. Here are the
details.

The analog of the gradient equation (17.13) is now

Θ−1

S

λ

Sign(Θ) = 0.

(17.22)

−
Here we use sub-gradient notation, with Sign(θjk) = sign(θjk) if θjk 6
else Sign(θjk)
previous section, we reach the analog of (17.18)

= 0,
1, 1] if θjk = 0. Continuing the development in the

−

−

∈

·

[

W11β

s12 + λ

·

−

Sign(β) = 0

(17.23)

(recall that β and θ12 have opposite signs). We will now see that this system
is exactly equivalent to the estimating equations for a lasso regression.

Consider the usual regression setup with outcome variables y and pre-

dictor matrix Z. There the lasso minimizes

1
2 (y

Zβ)T (y

Zβ) + λ

β

||1
−
[see (3.52) on page 68; here we have added a factor 1
2 for convenience]. The
gradient of this expression is

· ||

−

(17.24)

636

17. Undirected Graphical Models

Algorithm 17.2 Graphical Lasso.

1. Initialize W = S + λI. The diagonal of W remains unchanged in

what follows.

2. Repeat for j = 1, 2, . . . p, 1, 2, . . . p, . . . until convergence:

(a) Partition the matrix W into part 1: all but the jth row and

column, and part 2: the jth row and column.

(b) Solve the estimating equations W11β

Sign(β) = 0
using the cyclical coordinate-descent algorithm (17.26) for the
modiﬁed lasso.
(c) Update w12 = W11 ˆβ

s12 + λ

−

·

3. In the ﬁnal cycle (for each j) solve for ˆθ12 =

w22 −

wT
12

ˆβ.

ˆβ

·

−

ˆθ22, with 1/ˆθ22 =

ZT Zβ

−

ZT y + λ

·

Sign(β) = 0

(17.25)

So up to a factor 1/N , ZT y is the analog of s12, and we replace ZT Z by
W11, the estimated cross-product matrix from our current model.

The resulting procedure is called the graphical lasso, proposed by Fried-
man et al. (2008b) building on the work of Banerjee et al. (2008). It is
summarized in Algorithm 17.2.

Friedman et al. (2008b) use the pathwise coordinate descent method
(Section 3.8.6) to solve the modiﬁed lasso problem at each stage. Here are
the details of pathwise coordinate descent for the graphical lasso algorithm.
Letting V = W11, the update has the form
ˆβj ←

Vkj ˆβk, λ

s12j −

(17.26)

/Vjj

S

(cid:16)
1, 1, 2, . . . , p

Xk6=j
1, . . ., where S is the soft-threshold

(cid:17)

for j = 1, 2, . . . , p
operator:

−

−

S(x, t) = sign(x)(

x

|

| −

t)+.

(17.27)

The procedure cycles through the predictors until convergence.

It is easy to show that the diagonal elements wjj of the solution matrix

W are simply sjj + λ, and these are ﬁxed in step 1 of Algorithm 17.23.

The graphical lasso algorithm is extremely fast, and can solve a moder-
ately sparse problem with 1000 nodes in less than a minute. It is easy to
modify the algorithm to have edge-speciﬁc penalty parameters λjk; since

3An alternative formulation of the problem (17.21) can be posed, where we don’t
penalize the diagonal of Θ. Then the diagonal elements wjj of the solution matrix are
sjj , and the rest of the algorithm is unchanged.

17.3 Undirected Graphical Models for Continuous Variables

637

∞

will force ˆθjk to be zero, this algorithm subsumes Algorithm 17.1.
λjk =
By casting the sparse inverse-covariance problem as a series of regressions,
one can also quickly compute and examine the solution paths as a function
of the penalty parameter λ. More details can be found in Friedman et al.
(2008b).

λ = 36

Raf

λ = 27

Raf

Mek

Jnk

Mek

Jnk

Plcg

PIP2

P38

Plcg

PKC

PIP2

P38

PKC

PIP3

PKA

PIP3

PKA

Erk

Akt

Erk

Akt

λ = 7

Raf

λ = 0

Raf

Mek

Jnk

Mek

Jnk

Plcg

PIP2

P38

Plcg

PKC

PIP2

P38

PKC

PIP3

PKA

PIP3

PKA

Erk

Akt

Erk

Akt

FIGURE 17.5. Four diﬀerent graphical-lasso solutions for the ﬂow-cytometry
data.

Figure 17.1 shows the result of applying the graphical lasso to the ﬂow-
cytometry dataset. Here the lasso penalty parameter λ was set at 14. In
practice it is informative to examine the diﬀerent sets of graphs that are
obtained as λ is varied. Figure 17.5 shows four diﬀerent solutions. The
graph becomes more sparse as the penalty parameter is increased.

Finally note that the values at some of the nodes in a graphical model can
be unobserved; that is, missing or hidden. If only some values are missing
at a node, the EM algorithm can be used to impute the missing values

638

17. Undirected Graphical Models

(Exercise 17.9). However, sometimes the entire node is hidden or latent.
In the Gaussian model, if a node has all missing values, due to linearity
one can simply average over the missing nodes to yield another Gaussian
model over the observed nodes. Hence the inclusion of hidden nodes does
not enrich the resulting model for the observed nodes; in fact, it imposes
additional structure on its covariance matrix. However in the discrete model
(described next) the inherent nonlinearities make hidden units a powerful
way of expanding the model.

17.4 Undirected Graphical Models for Discrete

Variables

Undirected Markov networks with all discrete variables are popular, and
in particular pairwise Markov networks with binary variables being the
most common. They are sometimes called Ising models in the statistical
mechanics literature, and Boltzmann machines in the machine learning lit-
erature, where the vertices are referred to as “nodes” or “units” and are
binary-valued.

In addition, the values at each node can be observed (“visible”) or un-
observed (“hidden”). The nodes are often organized in layers, similar to a
neural network. Boltzmann machines are useful both for unsupervised and
supervised learning, especially for structured input data such as images,
but have been hampered by computational diﬃculties. Figure 17.6 shows
a restricted Boltzmann machine (discussed later), in which some variables
are hidden, and only some pairs of nodes are connected. We ﬁrst consider
the simpler case in which all p nodes are visible with edge pairs (j, k) enu-
merated in E.

Denoting the binary valued variable at node j by Xj, the Ising model

for their joint probabilities is given by

p(X, Θ) = exp

θjkXjXk −

Φ(Θ)

for X

i

h X(j,k)∈E

,

∈ X

(17.28)

X

=

p. As with the Gaussian model of the previous section,
0, 1
with
}
{
only pairwise interactions are modeled. The Ising model was developed in
statistical mechanics, and is now used more generally to model the joint
eﬀects of pairwise interactions. Φ(Θ) is the log of the partition function,
and is deﬁned by

Φ(Θ) = log

exp

θjkxjxk

.

(17.29)

Xx∈X h

(cid:16) X(j,k)∈E

(cid:17)i

The partition function ensures that the probabilities add to one over the
sample space. The terms θjkXjXk represent a particular parametrization

17.4 Undirected Graphical Models for Discrete Variables

639

of the (log) potential functions (17.5), and for technical reasons requires
1 to be included (Exercise 17.10), with “edges” to
a constant node X0 ≡
all the other nodes. In the statistics literature, this model is equivalent
to a ﬁrst-order-interaction Poisson log-linear model for multiway tables of
counts (Bishop et al., 1975; McCullagh and Nelder, 1989; Agresti, 2002).

The Ising model implies a logistic form for each node conditional on the

others (exercise 17.11):

Pr(Xj = 1
|

X−j = x−j) =

1 + exp(

1
θj0 −

−

(j,k)∈E θjkxk)

,

(17.30)

where X−j denotes all of the nodes except j. Hence the parameter θjk
measures the dependence of Xj on Xk, conditional on the other nodes.

P

17.4.1 Estimation of the Parameters when the Graph

Structure is Known

Given some data from this model, how can we estimate the parameters?
Suppose we have observations xi = (xi1, xi2, . . . , xip)
The log-likelihood is

p, i = 1, . . . , N .
0, 1
}

∈ {

ℓ(Θ) =

=

N

i=1
X
N

i=1
X

log PrΘ(Xi = xi)





X(j,k)∈E

θjkxijxik −

Φ(Θ)





The gradient of the log-likelihood is

∂ℓ(Θ)
∂θjk

=

N

i=1
X

xijxik −

N

∂Φ(Θ)
∂θjk

and

∂Φ(Θ)
∂θjk

p(x, Θ)

=

xjxk ·
= EΘ(XjXk)

Xx∈X

Setting the gradient to zero gives

ˆE(XjXk)

−

EΘ(XjXk) = 0

where we have deﬁned

(17.31)

(17.32)

(17.33)

(17.34)

640

17. Undirected Graphical Models

ˆE(XjXk) =

1
N

N

i=1
X

xijxik,

(17.35)

the expectation taken with respect to the empirical distribution of the data.
Looking at (17.34), we see that the maximum likelihood estimates simply
match the estimated inner products between the nodes to their observed
inner products. This is a standard form for the score (gradient) equation
for exponential family models, in which suﬃcient statistics are set equal to
their expectations under the model.

To ﬁnd the maximum likelihood estimates, we can use gradient search
or Newton methods. However the computation of EΘ(XjXk) involves enu-
meration of p(X, Θ) over 2p−2 of the
= 2p possible values of X, and is
not generally feasible for large p (e.g., larger than about 30). For smaller
p, a number of standard statistical approaches are available:

|X |

Poisson log-linear modeling, where we treat the problem as a large regres-
sion problem (Exercise 17.12). The response vector y is the vector of
2p counts in each of the cells of the multiway tabulation of the data4.
The predictor matrix Z has 2p rows and up to 1 + p + p2 columns that
characterize each of the cells, although this number depends on the
sparsity of the graph. The computational cost is essentially that of a
regression problem of this size, which is O(p42p) and is manageable
for p < 20. The Newton updates are typically computed by iteratively
reweighted least squares, and the number of steps is usually in the
single digits. See Agresti (2002) and McCullagh and Nelder (1989) for
details. Standard software (such as the R package glm) can be used
to ﬁt this model.

Gradient descent requires at most O(p22p−2) computations to compute
the gradient, but may require many more gradient steps than the
second–order Newton methods. Nevertheless, it can handle slightly
30. These computations can be reduced
larger problems with p
by exploiting the special clique structure in sparse graphs, using the
junction-tree algorithm. Details are not given here.

≤

Iterative proportional ﬁtting (IPF) performs cyclical coordinate descent on
the gradient equations (17.34). At each step a parameter is updated
so that its gradient equation is exactly zero. This is done in a cyclical
fashion until all the gradients are zero. One complete cycle costs the
same as a gradient evaluation, but may be more eﬃcient. Jirou´sek and
Pˇreuˇcil (1995) implement an eﬃcient version of IPF, using junction
trees.

4Each of the cell counts is treated as an independent Poisson variable. We get the
multinomial model corresponding to (17.28) by conditioning on the total count N (which
is also Poisson under this framework).

17.4 Undirected Graphical Models for Discrete Variables

641

When p is large (> 30) other approaches have been used to approximate

the gradient.

•

•

The mean ﬁeld approximation (Peterson and Anderson, 1987) esti-
mates EΘ(XjXk) by EΘ(Xj)EΘ(Xj), and replaces the input vari-
ables by their means, leading to a set of nonlinear equations for the
parameters θjk.

To obtain near-exact solutions, Gibbs sampling (Section 8.6) is used
to approximate EΘ(XjXk) by successively sampling from the esti-
mated model probabilities PrΘ(Xj|

X−j) (see e.g. Ripley (1996)).

We have not discussed decomposable models, for which the maximum
likelihood estimates can be found in closed form without any iteration
whatsoever. These models arise, for example, in trees: special graphs with
tree-structured topology. When computational tractability is a concern,
trees represent a useful class of models and they sidestep the computational
concerns raised in this section. For details, see for example Chapter 12 of
Whittaker (1990).

17.4.2 Hidden Nodes

We can increase the complexity of a discrete Markov network by including
latent or hidden nodes. Suppose that a subset of the variables XH are
unobserved or “hidden”, and the remainder XV are observed or “visible.”
Then the log-likelihood of the observed data is

ℓ(Θ) =

N

i=1
X
N

log[PrΘ(XV = xiV )]

=

log

exp

XxH∈XH
The sum over xH means that we are summing over all possible
for the hidden units. The gradient works out to be

X(j,k)∈E

i=1h
X

(θjkxijxik −

Φ(Θ))

. (17.36)

i

0, 1
}
{

values

(17.37)

dℓ(Θ)
dθjk

= ˆEV EΘ(XjXk|

XV )

−

EΘ(XjXk)

The ﬁrst term is an empirical average of XjXk if both are visible; if one
or both are hidden, they are ﬁrst imputed given the visible data, and then
averaged over the hidden variables. The second term is the unconditional
expectation of XjXk.

The inner expectation in the ﬁrst term can be evaluated using basic rules
of conditional expectation and properties of Bernoulli random variables. In
detail, for observation i

642

17. Undirected Graphical Models

if j, k
if j
if j, k

∈ V
, k

xijxik
xijPrΘ(Xk = 1
|
PrΘ(Xj = 1, Xk = 1
|

XV = xiV )

EΘ(XjXk|

XV = xiV ) =

(cid:8)

∈ V

XV = xiV )

∈ H
.
∈ H
(17.38)
Now two separate runs of Gibbs sampling are required; the ﬁrst to estimate
EΘ(XjXk) by sampling from the model as above, and the second to esti-
XV = xiV ). In this latter run, the visible units are ﬁxed
mate EΘ(XjXk|
(“clamped”) at their observed values and only the hidden variables are
sampled. Gibbs sampling must be done for each observation in the training
set, at each stage of the gradient search. As a result this procedure can be
very slow, even for moderate-sized models. In Section 17.4.4 we consider
further model restrictions to make these computations manageable.

17.4.3 Estimation of the Graph Structure

The use of a lasso penalty with binary pairwise Markov networks has been
suggested by Lee et al. (2007) and Wainwright et al. (2007). The ﬁrst au-
thors investigate a conjugate gradient procedure for exact maximization of
a penalized log-likelihood. The bottleneck is the computation of EΘ(XjXk)
in the gradient; exact computation via the junction tree algorithm is man-
ageable for sparse graphs but becomes unwieldy for dense graphs.

The second authors propose an approximate solution, analogous to the
Meinshausen and B¨uhlmann (2006) approach for the Gaussian graphical
model. They ﬁt an L1-penalized logistic regression model to each node as
a function of the other nodes, and then symmetrize the edge parameter
estimates in some fashion. For example if ˜θjk is the estimate of the j-k
edge parameter from the logistic model for outcome node j, the “min”
symmetrization sets ˆθjk to either ˜θjk or ˜θkj, whichever is smallest in abso-
lute value. The “max” criterion is deﬁned similarly. They show that under
certain conditions either approximation estimates the nonzero edges cor-
rectly as the sample size goes to inﬁnity. Hoeﬂing and Tibshirani (2008)
extend the graphical lasso to discrete Markov networks, obtaining a pro-
cedure which is somewhat faster than conjugate gradients, but still must
deal with computation of EΘ(XjXk). They also compare the exact and
approximate solutions in an extensive simulation study and ﬁnd the “min”
or “max” approximations are only slightly less accurate than the exact pro-
cedure, both for estimating the nonzero edges and for estimating the actual
values of the edge parameters, and are much faster. Furthermore, they can
handle denser graphs because they never need to compute the quantities
EΘ(XjXk).

Finally, we point out a key diﬀerence between the Gaussian and binary
models. In the Gaussian case, both Σ and its inverse will often be of interest,
and the graphical lasso procedure delivers estimates for both of these quan-
tities. However, the approximation of Meinshausen and B¨uhlmann (2006)
for Gaussian graphical models, analogous to the Wainwright et al. (2007)

17.4 Undirected Graphical Models for Discrete Variables

643

Xk

Hidden

H

θjk

Xj

Visible

V1

Xℓ

Visible

V2

FIGURE 17.6. A restricted Boltzmann machine (RBM) in which there are no
connections between nodes in the same layer. The visible units are subdivided to
allow the RBM to model the joint density of feature

1 and their labels

2.

V

V

approximation for the binary case, only yields an estimate of Σ−1. In con-
trast, in the Markov model for binary data, Θ is the object of interest, and
its inverse is not of interest. The approximate method of Wainwright et al.
(2007) estimates Θ eﬃciently and hence is an attractive solution for the
binary problem.

17.4.4 Restricted Boltzmann Machines

In this section we consider a particular architecture for graphical models
inspired by neural networks, where the units are organized in layers. A
restricted Boltzmann machine (RBM) consists of one layer of visible units
and one layer of hidden units with no connections within each layer. It
is much simpler to compute the conditional expectations (as in 17.37 and
17.38) if the connections between hidden units are removed 5. Figure 17.6
shows an example; the visible layer is divided into input variables
V1 and
output variables
. We denote such a
V2, and there is a hidden layer
network by

H

V1 ↔ H ↔ V2.

(17.39)

For example,
digit, and
0-9.

V1 could be the binary pixels of an image of a handwritten
V2 could have 10 units, one for each of the observed class labels
The restricted form of this model simpliﬁes the Gibbs sampling for es-
timating the expectations in (17.37), since the variables in each layer are
independent of one another, given the variables in the other layers. Hence
they can be sampled together, using the conditional probabilities given by
expression (17.30).

The resulting model is less general than a Boltzmann machine, but is still
useful; for example it can learn to extract interesting features from images.

5We thank Geoﬀrey Hinton for assistance in the preparation of the material on RBMs.

644

17. Undirected Graphical Models

By alternately sampling the variables in each layer of the RBM shown
in Figure 17.6, it is possible to generate samples from the joint density
V1 part of the visible layer is clamped at a particular feature
model. If the
vector during the alternating sampling, it is possible to sample from the
distribution over labels given
V1. Alternatively classiﬁcation of test items
can also be achieved by comparing the unnormalized joint densities of each
label category with the observed features. We do not need to compute the
partition function as it is the same for all of these combinations.

As noted the restricted Boltzmann machine has the same generic form
as a single hidden layer neural network (Section 11.3). The edges in the
latter model are directed, the hidden units are usually real-valued, and the
ﬁtting criterion is diﬀerent. The neural network minimizes the error (cross-
entropy) between the targets and their model predictions, conditional on
the input features. In contrast, the restricted Boltzmann machine maxi-
mizes the log-likelihood for the joint distribution of all visible units—that
is, the features and targets. It can extract information from the input fea-
tures that is useful for predicting the labels, but, unlike supervised learning
methods, it may also use some of its hidden units to model structure in the
feature vectors that is not immediately relevant for predicting the labels.
These features may turn out to be useful, however, when combined with
features derived from other hidden layers.

Unfortunately, Gibbs sampling in a restricted Boltzmann machine can
be very slow, as it can take a long time to reach stationarity. As the net-
work weights get larger, the chain mixes more slowly and we need to run
more steps to get the unconditional estimates. Hinton (2002) noticed em-
pirically that learning still works well if we estimate the second expectation
in (17.37) by starting the Markov chain at the data and only running for a
few steps (instead of to convergence). He calls this contrastive divergence:
we sample
V2
again. The idea is that when the parameters are far from the solution, it
may be wasteful to iterate the Gibbs sampler to stationarity, as just a single
iteration will reveal a good direction for moving the estimates.

V2 given

V2, then

and ﬁnally

V1,

V1,

V1,

given

given

H

H

H

We now give an example to illustrate the use of an RBM. Using con-
trastive divergence, it is possible to train an RBM to recognize hand-written
digits from the MNIST dataset (LeCun et al., 1998). With 2000 hidden
units, 784 visible units for representing binary pixel intensities and one
10-way multinomial visible unit for representing labels, the RBM achieves
an error rate of 1.9% on the test set. This is a little higher than the 1.4%
achieved by a support vector machine and comparable to the error rate
achieved by a neural network trained with backpropagation. The error rate
of the RBM, however, can be reduced to 1.25% by replacing the 784 pixel
intensities by 500 features that are produced from the images without using
any label information. First, an RBM with 784 visible units and 500 hidden
units is trained, using contrastive divergence, to model the set of images.
Then the hidden states of the ﬁrst RBM are used as data for training a

Exercises

645

FIGURE 17.7. Example of a restricted Boltzmann machine for handwritten
digit classiﬁcation. The network is depicted in the schematic on the left. Displayed
on the right are some diﬃcult test images that the model classiﬁes correctly.

second RBM that has 500 visible units and 500 hidden units. Finally, the
hidden states of the second RBM are used as the features for training an
RBM with 2000 hidden units as a joint density model. The details and
justiﬁcation for learning features in this greedy, layer-by-layer way are de-
scribed in Hinton et al. (2006). Figure 17.7 gives a representation of the
composite model that is learned in this way and also shows some examples
of the types of distortion that it can cope with.

Bibliographic Notes

Much work has been done in deﬁning and understanding the structure of
graphical models. Comprehensive treatments of graphical models can be
found in Whittaker (1990), Lauritzen (1996), Cox and Wermuth (1996),
Edwards (2000), Pearl (2000), Anderson (2003), Jordan (2004), and Koller
and Friedman (2007). Wasserman (2004) gives a brief introduction, and
Chapter 8 of Bishop (2006) gives a more detailed overview. Boltzmann
machines were proposed in Ackley et al. (1985). Ripley (1996) has a detailed
chapter on topics in graphical models that relate to machine learning. We
found this particularly useful for its discussion of Boltzmann machines.

Exercises

Ex. 17.1 For the Markov graph of Figure 17.8, list all of the implied condi-
tional independence relations and ﬁnd the maximal cliques.

646

17. Undirected Graphical Models

X1

X2

X3

X4

X5

X6

FIGURE 17.8.

X3|
X4|
X4|

X3.
X4|
X1, X3.
X2, X4 and X3 ⊥

Ex. 17.2 Consider random variables X1, X2, X3, X4. In each of the following
cases draw a graph that has the given independence relations:
X2 and X2 ⊥
(a) X1 ⊥
X4|
X2, X3 and X2 ⊥
(b) X1 ⊥
X3|
X2, X3, X1 ⊥
(c) X1 ⊥
Ex. 17.3 Let Σ be the covariance matrix of a set of p variables X. Consider
the partial covariance matrix Σa.b = Σaa −
bb Σba between the two
subsets of variables Xa = (X1, X2) consisting of the ﬁrst two, and Xb
the rest. This is the covariance matrix between these two variables, after
linear adjustment for all the rest. In the Gaussian distribution, this is the
Xb. The partial
covariance matrix of the conditional distribution of Xa|
correlation coeﬃcient ρjk|rest between the pair Xa conditional on the rest
Xb, is simply computed from this partial covariance. Deﬁne Θ = Σ−1.

ΣabΣ−1

X1, X2.

X4|

1. Show that Σa.b = Θ−1
aa .

2. Show that if any oﬀ-diagonal element of Θ is zero, then the partial
correlation coeﬃcient between the corresponding variables is zero.

3. Show that if we treat Θ as if it were a covariance matrix, and compute

the corresponding “correlation” matrix

R = diag(Θ)−1/2

diag(Θ)−1/2,

Θ

·

·

(17.40)

then rjk =

−
Ex. 17.4 Denote by

ρjk|rest

the conditional density of X1 given X2, . . . , Xp. If

f (X1|

X2, X3, . . . , Xp)

show that X1 ⊥

f (X1|
X2|

X2, X3, . . . , Xp) = f (X1|
X3, . . . , Xp.

X3, . . . , Xp),

Ex. 17.5 Consider the setup in Section 17.3.1 with no missing edges. Show
that

Exercises

647

are the estimating equations for the multiple regression coeﬃcients of the
last variable on the rest.

S11β

s12 = 0

−

Ex. 17.6 Recovery of ˆΘ = ˆΣ−1 from Algorithm 17.1. Use expression (17.16)
to derive the standard partitioned inverse expressions

W−1

θ12 =
−
12W−1
θ22 = 1/(w22 −
11 w12, show that ˆθ22 = 1/(w22 −

11 w12θ22
wT

Since ˆβ = W−1
Thus ˆθ12 is a simply rescaling of ˆβ by

ˆθ22.

−

11 w12).

wT
12

ˆβ) and ˆθ12 =

(17.41)

(17.42)

ˆβ ˆθ22.

−

Ex. 17.7 Write a program to implement the modiﬁed regression procedure
(17.1) for ﬁtting the Gaussian graphical model with pre-speciﬁed edges
missing. Test it on the ﬂow cytometry data from the book website, using
the graph of Figure 17.1.

Ex. 17.8

(a) Write a program to ﬁt the lasso using the coordinate descent procedure
(17.26). Compare its results to those from the lars program or some
other convex optimizer, to check that it is working correctly.

(b) Using the program from (a), write code to implement the graphical
lasso algorithm (17.2). Apply it to the ﬂow cytometry data from the
book website. Vary the regularization parameter and examine the
resulting networks.

Ex. 17.9 Suppose that we have a Gaussian graphical model in which some
or all of the data at some vertices are missing.

(a) Consider the EM algorithm for a dataset of N i.i.d. multivariate ob-
IRp with mean µ and covariance matrix Σ. For each
servations xi ∈
sample i, let oi and mi index the predictors that are observed and
missing, respectively. Show that in the E step, the observations are
imputed from the current estimates of µ and Σ:

ˆxi,mi = E(xi,mi |

xi,oi , θ) = ˆµmi + ˆΣmi,oi

ˆΣ−1
oi,oi (xi,oi −

ˆµoi )

(17.43)

while in the M step, µ and Σ are re-estimated from the empirical
mean and (modiﬁed) covariance of the imputed data:

N

ˆµj =

ˆxij/N

i=1
X

648

17. Undirected Graphical Models

N

ˆΣjj′ =

[(ˆxij −

−

ˆµj)(ˆxij′

ˆµj′ ) + ci,jj′ ]/N

(17.44)

i=1
X
where ci,jj′ = ˆΣjj′ if j, j′
for the correction term ci,jj′ (Little and Rubin, 2002).

∈

mi and zero otherwise. Explain the reason

(b) Implement the EM algorithm for the Gaussian graphical model using
the modiﬁed regression procedure from Exercise 17.7 for the M-step.

(c) For the ﬂow cytometry data on the book website, set the data for the
last protein Jnk in the ﬁrst 1000 observations to missing, ﬁt the model
of Figure 17.1, and compare the predicted values to the actual values
for Jnk. Compare the results to those obtained from a regression of
Jnk on the other vertices with edges to Jnk in Figure 17.1, using only
the non-missing data.

Ex. 17.10 Using a simple binary graphical model with just two variables,
show why it is essential to include a constant node X0 ≡
Ex. 17.11 Show that the Ising model (17.28) for the joint probabilities in
a discrete graphical model implies that the conditional distributions have
the logistic form (17.30).

1 in the model.

Ex. 17.12 Consider a Poisson regression problem with p binary variables
xij, j = 1, . . . , p and response variable yi which measures the number of
p. The design is balanced, in that all
0, 1
observations with predictor xi ∈ {
}
n = 2p possible combinations are measured. We assume a log-linear model
for the Poisson mean in each cell

log µ(X) = θ00 +

xijxikθjk,

(17.45)

X(j,k)∈E

using the same notation as in Section 17.4.1 (including the constant variable
xi0 = 1

i). We assume the response is distributed as

∀

Pr(Y = y

|

X = x) =

e−µ(x)µ(x)y
y!

.

(17.46)

Write down the conditional log-likelihood for the observed responses yi,
and compute the gradient.

(a) Show that the gradient equation for θ00 computes the partition func-

tion (17.29).

(b) Show that the gradient equations for the remainder of the parameters

are equivalent to the gradient (17.34).

This is page 649
Printer: Opaque this

18
High-Dimensional Problems: p

N

≫

18.1 When p is Much Bigger than N

≫

In this chapter we discuss prediction problems in which the number of
features p is much larger than the number of observations N , often written
p
N . Such problems have become of increasing importance, especially in
genomics and other areas of computational biology. We will see that high
variance and overﬁtting are a major concern in this setting. As a result,
simple, highly regularized approaches often become the methods of choice.
The ﬁrst part of the chapter focuses on prediction in both the classiﬁcation
and regression settings, while the second part discusses the more basic
problem of feature selection and assessment.

To get us started, Figure 18.1 summarizes a small simulation study that
demonstrates the “less ﬁtting is better” principle that applies when p
N .
For each of N = 100 samples, we generated p standard Gaussian features
X with pairwise correlation 0.2. The outcome Y was generated according
to a linear model

≫

p

Y =

Xjβj + σε

j=1
X

(18.1)

where ε was generated from a standard Gaussian distribution. For each
dataset, the set of coeﬃcients βj were also generated from a standard Gaus-
sian distribution. We investigated three cases: p = 20, 100, and 1000. The
standard deviation σ was chosen in each case so that the signal-to-noise
X)]/σ2 equaled 2. As a result, the number of signiﬁcant uni-
ratio Var[E(Y

|

650

18. High-Dimensional Problems: p

N

≫

20 features

100 features

1000 features

r
o
r
r
e

e
v
i
t
a
e
R

l

r
o
r
r

E

t
s
e
T

0
.
3

5
.
2

0
.
2

5
.
1

0
.
1

0
.
3

5
.
2

0
.
2

5
.
1

0
.
1

0
.
3

5
.
2

0
.
2

5
.
1

0
.
1

20

9

2

99

35

7

99

87

43

Effective Degrees of Freedom

FIGURE 18.1. Test-error results for simulation experiments. Shown are box-
plots of the relative test errors over 100 simulations, for three diﬀerent values
of p, the number of features. The relative error is the test error divided by the
Bayes error, σ2. From left to right, results are shown for ridge regression with
three diﬀerent values of the regularization parameter λ: 0.001, 100 and 1000. The
(average) eﬀective degrees of freedom in the ﬁt is indicated below each plot.

variate regression coeﬃcients1 was 9, 33 and 331, respectively, averaged
over the 100 simulation runs. The p = 1000 case is designed to mimic the
kind of data that we might see in a high-dimensional genomic or proteomic
dataset, for example.

We ﬁt a ridge regression to the data, with three diﬀerent values for the
regularization parameter λ: 0.001, 100, and 1000. When λ = 0.001, this
is nearly the same as least squares regression, with a little regularization
just to ensure that the problem is non-singular when p > N . Figure 18.1
shows boxplots of the relative test error achieved by the diﬀerent estimators
in each scenario. The corresponding average degrees of freedom used in
each ridge-regression ﬁt is indicated (computed using formula (3.50) on
page 682). The degrees of freedom is a more interpretable parameter than
λ. We see that ridge regression with λ = 0.001 (20 df) wins when p = 20;
λ = 100 (35 df) wins when p = 100, and λ = 1000 (43 df) wins when
p = 1000,

Here is an explanation for these results. When p = 20, we ﬁt all the way
and we can identify as many of the signiﬁcant coeﬃcients as possible with

1We call a regression coeﬃcient signiﬁcant if |

βj /
b

sej | ≥ 2, where ˆβj is the estimated
b

(univariate) coeﬃcient and

sej is its estimated standard error.
b
2For a ﬁxed value of the regularization parameter λ, the degrees of freedom depends
on the observed predictor values in each simulation. Hence we compute the average
degrees of freedom over simulations.

 
 
18.2 Nearest Shrunken Centroids

651

low bias. When p = 100, we can identify some non-zero coeﬃcients using
moderate shrinkage. Finally, when p = 1000, even though there are many
nonzero coeﬃcients, we don’t have a hope for ﬁnding them and we need
sej, where ˆβj
to shrink all the way down. As evidence of this, let tj =
is the ridge regression estimate and
sej its estimated standard error. Then
using the optimal ridge parameter in each of the three cases, the median
b
value of
values
was 2.0, 0.6 and 0.2, and the average number of
b
exceeding 2 was equal to 9.8, 1.2 and 0.0.

tj|

tj|

βj/

b

|

|

Ridge regression with λ = 0.001 successfully exploits the correlation in
N . In the latter case
the features when p < N , but cannot do so when p
there is not enough information in the relatively small number of samples
to eﬃciently estimate the high-dimensional covariance matrix. In that case,
more regularization leads to superior prediction performance.

≫

Thus it is not surprising that the analysis of high-dimensional data re-
quires either modiﬁcation of procedures designed for the N > p scenario, or
entirely new procedures. In this chapter we discuss examples of both kinds
of approaches for high dimensional classiﬁcation and regression; these meth-
ods tend to regularize quite heavily, using scientiﬁc contextual knowledge
to suggest the appropriate form for this regularization. The chapter ends
with a discussion of feature selection and multiple testing.

18.2 Diagonal Linear Discriminant Analysis and

Nearest Shrunken Centroids

Gene expression arrays are an important new technology in biology, and
are discussed in Chapters 1 and 14. The data in our next example form
a matrix of 2308 genes (columns) and 63 samples (rows), from a set of
microarray experiments. Each expression value is a log-ratio log(R/G). R
is the amount of gene-speciﬁc RNA in the target sample that hybridizes
to a particular (gene-speciﬁc) spot on the microarray, and G is the corre-
sponding amount of RNA from a reference sample. The samples arose from
small, round blue-cell tumors (SRBCT) found in children, and are classiﬁed
into four major types: BL (Burkitt lymphoma), EWS (Ewing’s sarcoma),
NB (neuroblastoma), and RMS (rhabdomyosarcoma). There is an addi-
tional test data set of 20 observations. We will not go into the scientiﬁc
background here.

≫

Since p

N , we cannot ﬁt a full linear discriminant analysis (LDA) to
the data; some sort of regularization is needed. The method we describe
here is similar to the methods of Section 4.3.1, but with important modiﬁ-
cations that achieve feature selection. The simplest form of regularization
assumes that the features are independent within each class, that is, the
within-class covariance matrix is diagonal. Despite the fact that features
N we don’t have
will rarely be independent within a class, when p

≫

652

18. High-Dimensional Problems: p

N

≫

enough data to estimate their dependencies. The assumption of indepen-
dence greatly reduces the number of parameters in the model and often
results in an eﬀective and interpretable classiﬁer.

Thus we consider the diagonal-covariance LDA rule for classifying the

classes. The discriminant score [see (4.12) on page 110] for class k is

δk(x∗) =

p

−

j=1
X

(x∗

¯xkj)2

j −
s2
j

+ 2 log πk.

(18.2)

i∈Ck

1, x∗

2, . . . , x∗

p)T is a vector of expression values for a test ob-
Here x∗ = (x∗
servation, sj is the pooled within-class standard deviation of the jth gene,
xij/Nk is the mean of the Nk values for gene j in class
and ¯xkj =
k, with Ck being the index set for class k. We call ˜xk = (¯xk1, ¯xk2, . . . ¯xkp)T
the centroid of class k. The ﬁrst part of (18.2) is simply the (negative)
standardized squared distance of x∗ to the kth centroid. The second part
K
is a correction based on the class prior probability πk, where
k=1 πk = 1.
The classiﬁcation rule is then

P

C(x∗) = ℓ if δℓ(x∗) = maxk δk(x∗).

(18.3)

P

We see that the diagonal LDA classiﬁer is equivalent to a nearest centroid
classiﬁer after appropriate standardization. It is also a special case of the
naive-Bayes classiﬁer, as described in Section 6.6.3. It assumes that the
features in each class have independent Gaussian distributions with the
same variance.

The diagonal LDA classiﬁer is often eﬀective in high dimensional set-
tings. It is also called the “independence rule” in Bickel and Levina (2004),
who demonstrate theoretically that it will often outperform standard lin-
ear discriminant analysis in high-dimensional problems. Here the diagonal
LDA classiﬁer yielded ﬁve misclassiﬁcation errors for the 20 test samples.
One drawback of the diagonal LDA classiﬁer is that it uses all of the fea-
tures (genes), and hence is not convenient for interpretation. With further
regularization we can do better—both in terms of test error and inter-
pretability.

We would like to regularize in a way that automatically drops out fea-
tures that are not contributing to the class predictions. We can do this
by shrinking the classwise mean toward the overall mean, for each feature
separately. The result is a regularized version of the nearest centroid clas-
siﬁer, or equivalently a regularized version of the diagonal-covariance form
of LDA. We call the procedure nearest shrunken centroids (NSC).

The shrinkage procedure is deﬁned as follows. Let

dkj =

¯xj

¯xkj −
mk(sj + s0)

,

(18.4)

where ¯xj is the overall mean for gene j, m2
1/N and s0 is a
small positive constant, typically chosen to be the median of the sj values.

k = 1/Nk −

18.2 Nearest Shrunken Centroids

653

∆

(0,0)

FIGURE 18.2. Soft thresholding function sign(x)(
along with the 45◦ line in red.

|

x

| −

∆)+ is shown in orange,

This constant guards against large dkj values that arise from expression
values near zero. With constant within-class variance σ2, the variance of
kσ2, and hence the form of the
the contrast ¯xkj −
standardization in the denominator. We shrink the dkj toward zero using
soft thresholding

¯xj in the numerator is m2

d′
kj = sign(dkj)(

dkj| −

|

∆)+;

(18.5)

see Figure 18.2. Here ∆ is a parameter to be determined; we used 10-fold
cross-validation in the example (see the top panel of Figure 18.4). Each dkj
is reduced by an amount ∆ in absolute value, and is set to zero if its value
is less than zero. The soft-thresholding function is shown in Figure 18.2;
the same thresholding is applied to wavelet coeﬃcients in Section 5.9. An
alternative is to use hard thresholding

d′
kj = dkj ·

I(

dkj| ≥

|

∆);

(18.6)

we prefer soft-thresholding, as it is a smoother operation and typically
works better. The shrunken versions of ¯xkj are then obtained by reversing
the transformation in (18.4):

kj = ¯xj + mk(sj + s0)d′
¯x′

kj.

(18.7)

We then use the shrunken centroids ¯x′
kj in place of the original ¯xkj in the
discriminant score (18.2). The estimator (18.5) can also be viewed as a
lasso-style estimator for the class means (Exercise 18.2).

Notice that only the genes that have a nonzero d′

kj for at least one of the
classes play a role in the classiﬁcation rule, and hence the vast majority
of genes can often be discarded. In this example, all but 43 genes were
discarded, leaving a small interpretable set of genes that characterize each
class. Figure 18.3 represents the genes in a heatmap.

Figure 18.4 (top panel) demonstrates the eﬀectiveness of the shrinkage.
With no shrinkage we make 5/20 errors on the test data, and several errors

654

18. High-Dimensional Problems: p

N

≫

on the training and CV data. The shrunken centroids achieve zero test er-
rors for a fairly broad band of values for ∆. The bottom panel of Figure 18.4
shows the four centroids for the SRBCT data (gray), relative to the overall
centroid. The blue bars are shrunken versions of these centroids, obtained
by soft-thresholding the gray bars, using ∆ = 4.3. The discriminant scores
(18.2) can be used to construct class probability estimates:

ˆpk(x∗) =

1

2 δk(x∗)

e
K
ℓ=1 e 1

2 δℓ(x∗)

.

(18.8)

These can be used to rate the classiﬁcations, or to decide not to classify a
particular sample at all.

P

Note that other forms of feature selection can be used in this setting,
including hard thresholding. Fan and Fan (2008) show theoretically the
importance of carrying out some kind of feature selection with diagonal
linear discriminant analysis in high-dimensional problems.

18.3 Linear Classiﬁers with Quadratic

Regularization

Ramaswamy et al. (2001) present a more diﬃcult microarray classiﬁcation
problem, involving a training set of 144 patients with 14 diﬀerent types of
cancer, and a test set of 54 patients. Gene expression measurements were
available for 16, 063 genes.

Table 18.1 shows the prediction results from eight diﬀerent classiﬁcation
methods. The data from each patient was ﬁrst standardized to have mean
0 and variance 1; this seems to improve prediction accuracy overall this
example, suggesting that the “shape” of each gene-expression proﬁle is
important, rather than the absolute expression levels. In each case, the

BL

EWS

NB

RMS

FIGURE 18.3. Heat-map of the chosen 43 genes. Within each of the horizontal
partitions, we have ordered the genes by hierarchical clustering, and similarly
for the samples within each vertical partition. Yellow represents over- and blue
under-expression.

18.3 Linear Classiﬁers with Quadratic Regularization

655

Number of Genes

2308 2059 1223

598

284

159

81

43

23

15

10

5

1

Training
10−fold CV
Test

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

0

2

4

6

Amount of Shrinkage ∆

BL

EWS

NB

RMS

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

l

i

e
n
e
G

0
0
0
2

0
0
5
1

0
0
0
1

0
0
5

0

−1.0 −0.5

0.0

0.5

1.0

−1.0 −0.5

0.0

0.5

1.0

−1.0 −0.5

0.0

0.5

1.0

−1.0 −0.5

0.0

0.5

1.0

Centroids: Average Expression Centered at Overall Centroid

FIGURE 18.4. (Top): Error curves for the SRBCT data. Shown are the train-
ing, 10-fold cross-validation, and test misclassiﬁcation errors as the threshold
parameter ∆ is varied. The value ∆ = 4.34 is chosen by CV, resulting in a sub-
set of 43 selected genes. (Bottom): Four centroids proﬁles dkj for the SRBCT
data (gray), relative to the overall centroid. Each centroid has 2308 components,
and we see considerable noise. The blue bars are shrunken versions d′
kj of these
centroids, obtained by soft-thresholding the gray bars, using ∆ = 4.3.

 
656

18. High-Dimensional Problems: p

N

≫

TABLE 18.1. Prediction results for microarray data with 14 cancer classes.
Method 1 is described in Section 18.2. Methods 2, 3 and 6 are discussed in Sec-
tion 18.3, while 4, 7 and 8 are discussed in Section 18.4. Method 5 is described in
Section 13.3. The elastic-net penalized multinomial does the best on the test data,
but the standard error of each test-error estimate is about 3, so such comparisons
are inconclusive.

Methods

CV errors (SE) Test errors
Out of 144

Out of 54

Number of
Genes Used

1. Nearest shrunken centroids
2. L2-penalized discriminant

35 (5.0)
25 (4.1)

analysis

3. Support vector classiﬁer
4. Lasso regression (one vs all)
5. k-nearest neighbors
6. L2-penalized multinomial
7. L1-penalized multinomial
8. Elastic-net penalized

26 (4.2)
30.7 (1.8)
41 (4.6)
26 (4.2)
17 (2.8)
22 (3.7)

multinomial

17
12

14
12.5
26
15
13
11.8

6,520
16,063

16,063
1,429
16,063
16,063
269
384

regularization parameter has been chosen to minimize the cross-validation
error, and the test error at that value of the parameter is shown. When
more than one value of the regularization parameter yields the minimal
cross-validation error, the average test error at these values is reported.

RDA (regularized discriminant analysis), regularized multinomial logistic
regression, and the support vector machine are more complex methods that
try to exploit multivariate information in the data. We describe each in
turn, as well as a variety of regularization methods, including both L1 and
L2 and some in between.

18.3.1 Regularized Discriminant Analysis

Regularized discriminant analysis (RDA) is described in Section 4.3.1. Lin-
ear discriminant analysis involves the inversion of a p
p within-covariance
matrix. When p
N , this matrix can be huge, has rank at most N < p,
and hence is singular. RDA overcomes the singularity issues by regulariz-
ing the within-covariance estimate ˆΣ. Here we use a version of RDA that
shrinks ˆΣ towards its diagonal:

≫

×

ˆΣ(γ) = γ ˆΣ + (1

−

γ)diag( ˆΣ), with γ

[0, 1].

∈

(18.9)

Note that γ = 0 corresponds to diagonal LDA, which is the “no shrinkage”
version of nearest shrunken centroids. The form of shrinkage in (18.9) is

18.3 Linear Classiﬁers with Quadratic Regularization

657

much like ridge regression (Section 3.4.1), which shrinks the total covariance
matrix of the features towards a diagonal (scalar) matrix. In fact, viewing
linear discriminant analysis as linear regression with optimal scoring of the
categorical response [see (12.58) in Section 12.6], the equivalence becomes
more precise.

The computational burden of inverting this large p

p matrix is overcome
using the methods discussed in Section 18.3.5. The value of γ was chosen
by cross-validation in line 2 of Table 18.1; all values of γ
(0.002, 0.550)
gave the same CV and test error. Further development of RDA, including
shrinkage of the centroids in addition to the covariance matrix, can be
found in Guo et al. (2006).

×

∈

18.3.2 Logistic Regression with Quadratic Regularization

Logistic regression (Section 4.4) can be modiﬁed in a similar way, to deal
with the p
N case. With K classes, we use a symmetric version of the
multiclass logistic model (4.17) on page 119:

≫

Pr(G = k

|

X = x) =

exp(βk0 + xT βk)
K
ℓ=1 exp(βℓ0 + xT βℓ)

.

(18.10)

P
This has K coeﬃcient vectors of log-odds parameters β1, β2, . . . , βK . We
regularize the ﬁtting by maximizing the penalized log-likelihood

N

max
{β0k,βk}K

1 "

i=1
X

log Pr(gi|

xi)

−

λ
2

K

Xk=1

2
2

βk||

||

.

#

(18.11)

P

K
k=1

This regularization automatically resolves the redundancy in the paramet-
ˆβkj = 0, j = 1, . . . , p (Exercise 18.3). Note that
rization, and forces
the constant terms βk0 are not regularized (and so one should be set to
zero). The resulting optimization problem is convex, and can be solved by
a Newton algorithm or other numerical techniques. Details are given in Zhu
and Hastie (2004). Friedman et al. (2010) provide software for computing
the regularization path for the two- and multiclass logistic regression mod-
els. Table 18.1, line 6 reports the results for the multiclass logistic regres-
sion model, referred to there as “multinomial”. It can be shown (Rosset
et al., 2004a) that for separable data, as λ
0, the regularized (two-
class) logistic regression estimate (renormalized) converges to the maximal
margin classiﬁer (Section 12.2). This gives an attractive alternative to the
support-vector machine, discussed next, especially in the multiclass case.

→

18.3.3 The Support Vector Classiﬁer

The support vector classiﬁer is described for the two-class case in Sec-
tion 12.2. When p > N , it is especially attractive because in general the

658

18. High-Dimensional Problems: p

N

≫

classes are perfectly separable by a hyperplane unless there are identical
feature vectors in diﬀerent classes. Without any regularization the support
vector classiﬁer ﬁnds the separating hyperplane with the largest margin;
that is, the hyperplane yielding the biggest gap between the classes in
the training data. Somewhat surprisingly, when p
N the unregularized
support vector classiﬁer often works about as well as the best regularized
version. Overﬁtting often does not seem to be a problem, partly because of
the insensitivity of misclassiﬁcation loss.

≫

K
2

There are many diﬀerent methods for generalizing the two-class support-
vector classiﬁer to K > 2 classes. In the “one versus one” (ovo) approach,
pairwise classiﬁers. For each test point, the predicted
we compute all
class is the one that wins the most pairwise contests. In the “one versus all”
(ova) approach, each class is compared to all of the others in K two-class
comparisons. To classify a test point, we compute the conﬁdences (signed
distance from the hyperplane) for each of the K classiﬁers. The winner is the
class with the highest conﬁdence. Finally, Vapnik (1998) and Weston and
Watkins (1999) suggested (somewhat complex) multiclass criteria which
generalize the two-class criterion (12.6).

(cid:1)

(cid:0)

Tibshirani and Hastie (2007) propose the margin tree classiﬁer, in which
support-vector classiﬁers are used in a binary tree, much as in CART
(Chapter 9). The classes are organized in a hierarchical manner, which can
be useful for classifying patients into diﬀerent cancer types, for example.

Line 3 of Table 18.1 shows the results for the support vector classiﬁer
using the ova method; Ramaswamy et al. (2001) reported (and we con-
ﬁrmed) that this approach worked best for this problem. The errors are
very similar to those in line 6, as we might expect from the comments
at the end of the previous section. The error rates are insensitive to the
choice of C [the regularization parameter in (12.8) on page 420], for values
of C > 0.001. Since p > N , the support vector hyperplane can perfectly
separate the training data by setting C =

.

∞

18.3.4 Feature Selection

Feature selection is an important scientiﬁc requirement for a classiﬁer when
p is large. Neither discriminant analysis, logistic regression, nor the support-
vector classiﬁer perform feature selection automatically, because all use
quadratic regularization. All features have nonzero weights in both models.
Ad-hoc methods for feature selection have been proposed, for example,
removing genes with small coeﬃcients, and reﬁtting the classiﬁer. This is
done in a backward stepwise manner, starting with the smallest weights and
moving on to larger weights. This is known as recursive feature elimination
(Guyon et al., 2002). It was not successful in this example; Ramaswamy
et al. (2001) report, for example, that the accuracy of the support-vector
classiﬁer starts to degrade as the number of genes is reduced from the full

18.3 Linear Classiﬁers with Quadratic Regularization

659

set of 16, 063. This is rather remarkable, as the number of training samples
is only 144. We do not have an explanation for this behavior.

≫

All three methods discussed in this section (RDA, LR and SVM) can
be modiﬁed to ﬁt nonlinear decision boundaries using kernels. Usually the
motivation for such an approach is to increase the model complexity. With
N the models are already suﬃciently complex and overﬁtting is always
p
a danger. Yet despite the high dimensionality, radial kernels (Section 12.3.3)
sometimes deliver superior results in these high dimensional problems. The
radial kernel tends to dampen inner products between points far away from
each other, which in turn leads to robustness to outliers. This occurs often
in high dimensions, and may explain the positive results. We tried a radial
kernel with the SVM in Table 18.1, but in this case the performance was
inferior.

18.3.5 Computational Shortcuts When p

N

≫

The computational techniques discussed in this section apply to any method
that ﬁts a linear model with quadratic regularization on the coeﬃcients.
That includes all the methods discussed in this section, and many more.
When p > N , the computations can be carried out in an N -dimensional
space, rather than p, via the singular value decomposition introduced in
Section 14.5. Here is the geometric intuition: just like two points in three-
dimensional space always lie on a line, N points in p-dimensional space lie
in an (N

−

1)-dimensional aﬃne subspace.
p data matrix X, let

Given the N

×

X = UDVT
= RVT

(18.12)

(18.13)

N with
N orthogonal, and D a diagonal matrix
N , with rows rT
i .
As a simple example, let’s ﬁrst consider the estimates from a ridge re-

be the singular-value decomposition (SVD) of X; that is, V is p
orthonormal columns, U is N
dN ≥
with elements d1 ≥
gression:

×
0. The matrix R is N

d2 ≥

ˆβ = (XT X + λI)−1XT y.
Replacing X by RVT and after some further manipulations, this can be
shown to equal

(18.14)

×

×

ˆβ = V(RT R + λI)−1RT y

(18.15)

(Exercise 18.4). Thus ˆβ = Vˆθ, where ˆθ is the ridge-regression estimate
using the N observations (ri, yi), i = 1, 2, . . . , N . In other words, we can
simply reduce the data matrix from X to R, and work with the rows of
R. This trick reduces the computational cost from O(p3) to O(pN 2) when
p > N .

660

18. High-Dimensional Problems: p

N

≫

These results can be generalized to all models that are linear in the
parameters and have quadratic penalties. Consider any supervised learning
problem where we use a linear function f (X) = β0 + X T β to model a
parameter in the conditional distribution of Y
X. We ﬁt the parameters β
N
by minimizing some loss function
i=1 L(yi, f (xi)) over the data with a
quadratic penalty on β. Logistic regression is a useful example to have in
P
mind. Then we have the following simple theorem:
Let f ∗(ri) = θ0 + rT
optimization problems:

i θ with ri deﬁned in (18.13), and consider the pair of

|

( ˆβ0, ˆβ) = arg min

β0,β∈IRp

(ˆθ0, ˆθ) = arg min

θ0,θ∈IRN

N

i=1
X
N

i=1
X

L(yi, β0 + xT

i β) + λβT β;

(18.16)

L(yi, θ0 + rT

i θ) + λθT θ.

(18.17)

Then the ˆβ0 = ˆθ0, and ˆβ = Vˆθ.

The theorem says that we can simply replace the p vectors xi by the
N -vectors ri, and perform our penalized ﬁt as before, but with far fewer
predictors. The N -vector solution ˆθ is then transformed back to the p-
vector solution via a simple matrix multiplication. This result is part of
the statistics folklore, and deserves to be known more widely—see Hastie
and Tibshirani (2004) for further details.

Geometrically, we are rotating the features to a coordinate system in
which all but the ﬁrst N coordinates are zero. Such rotations are allowed
since the quadratic penalty is invariant under rotations, and linear models
are equivariant.

This result can be applied to many of the learning methods discussed
in this chapter, such as regularized (multiclass) logistic regression, linear
discriminant analysis (Exercise 18.6), and support vector machines. It also
applies to neural networks with quadratic regularization (Section 11.5.2).
Note, however, that it does not apply to methods such as the lasso, which
uses nonquadratic (L1) penalties on the coeﬃcients.

Typically we use cross-validation to select the parameter λ. It can be
seen (Exercise 18.12) that we only need to construct R once, on the original
data, and use it as the data for each of the CV folds.

The support vector “kernel trick” of Section 12.3.7 exploits the same re-
duction used in this section, in a slightly diﬀerent context. Suppose we have
N gram (inner-product) matrix K = XXT . From
at our disposal the N
(18.12) we have K = UD2UT , and so K captures the same information as
R. Exercise 18.13 shows how we can exploit the ideas in this section to ﬁt
a ridged logistic regression with K using its SVD.

×

18.4 Linear Classiﬁers with L1 Regularization

661

18.4 Linear Classiﬁers with L1 Regularization

The methods of Section 18.3 use an L2 penalty to regularize their pa-
rameters, just as in ridge regression. All of the estimated coeﬃcients are
nonzero, and hence no feature selection is performed. In this section we dis-
cuss methods that use L1 penalties instead, and hence provide automatic
feature selection.

Recall the lasso of Section 3.4.2,

N

min
β

1
2

yi −

β0 −

p

xijβj

2

+ λ

p

,

(18.18)

βj|

|

i=1(cid:16)
X

j=1
X
which we have written in the Lagrange form (3.52). As discussed there, the
use of the L1 penalty causes a subset of the solution coeﬃcients ˆβj to be
exactly zero, for a suﬃciently large value of the tuning parameter λ.

j=1
X

(cid:17)

In Section 3.8.1 we discussed the LARS algorithm, an eﬃcient procedure
for computing the lasso solution for all λ. When p > N (as in this chapter),
as λ approaches zero, the lasso ﬁts the training data exactly. In fact, by
convex duality one can show that when p > N the number of non-zero
coeﬃcients is at most N for all values of λ (Rosset and Zhu, 2007, for
example). Thus the lasso provides a (severe) form of feature selection.

Lasso regression can be applied to a two-class classiﬁcation problem by
coding the outcome
1, and applying a cutoﬀ (usually 0) to the predictions.
For more than two classes, there are many possible approaches, including
the ova and ovo methods discussed in Section 18.3.3. We tried the ova-
approach on the cancer data in Section 18.3. The results are shown in
line (4) of Table 18.1. Its performance is among the best.

±

A more natural approach for classiﬁcation problems is to use the lasso
penalty to regularize logistic regression. Several implementations have been
proposed in the literature, including path algorithms similar to LARS (Park
and Hastie, 2007). Because the paths are piecewise smooth but nonlinear,
exact methods are slower than the LARS algorithm, and are less feasible
when p is large.

Friedman et al. (2010) provide very fast algorithms for ﬁtting L1-pen-
alized logistic and multinomial regression models. They use the symmetric
multinomial logistic regression model as in (18.10) in Section 18.3.2, and
maximize the penalized log-likelihood

max
{β0k,βk∈IRp}K

1 



N

i=1
X

log Pr(gi|

xi)

−

λ

K

p

|

Xk=1

j=1
X

βkj|


;

(18.19)

compare with (18.11). Their algorithm computes the exact solution at a
pre-chosen sequence of values for λ by cyclical coordinate descent (Sec-
N ,
tion 3.8.6), and exploits the fact that solutions are sparse when p

≫

662

18. High-Dimensional Problems: p

N

≫

as well as the fact that solutions for neighboring values of λ tend to be
very similar. This method was used in line (7) of Table 18.1, with the over-
all tuning parameter λ chosen by cross-validation. The performance was
similar to that of the best methods, except here the automatic feature se-
lection chose 269 genes altogether. A similar approach is used in Genkin
et al. (2007); although they present their model from a Bayesian point of
view, they in fact compute the posterior mode, which solves the penalized
maximum-likelihood problem.

Lasso

Elastic Net

s
t
n
e
i
c
ﬃ
e
o
C

0
.
2

5
.
1

0
.
1

5
.
0

0
.
0

s
t
n
e
i
c
ﬃ
e
o
C

0
.
2

5
.
1

0
.
1

5
.
0

0
.
0

−8

−7

−6

−5

−4

−3

−2

−1

−8

−7

−6

−5

−4

−3

−2

−1

log(λ)

log(λ)

FIGURE 18.5. Regularized logistic regression paths for the leukemia data. The
left panel is the lasso path, the right panel the elastic-net path with α = 0.8. At
the ends of the path (extreme left), there are 19 nonzero coeﬃcients for the lasso,
and 39 for the elastic net. The averaging eﬀect of the elastic net results in more
non-zero coeﬃcients than the lasso, but with smaller magnitudes.

In genomic applications, there are often strong correlations among the
variables; genes tend to operate in molecular pathways. The lasso penalty
is somewhat indiﬀerent to the choice among a set of strong but corre-
lated variables (Exercise 3.28). The ridge penalty, on the other hand, tends
to shrink the coeﬃcients of correlated variables toward each other (Exer-
cise 3.29 on page 99). The elastic net penalty (Zou and Hastie, 2005) is a
compromise, and has the form

p

j=1
X

(cid:0)

α

βj|

|

+ (1

−

α)β2
j

.

(cid:1)

(18.20)

The second term encourages highly correlated features to be averaged, while
the ﬁrst term encourages a sparse solution in the coeﬃcients of these aver-

18.4 Linear Classiﬁers with L1 Regularization

663

aged features. The elastic net penalty can be used with any linear model,
in particular for regression or classiﬁcation.

Hence the multinomial problem above with elastic-net penalty becomes

N

K

p

max
{β0k,βk∈IRp}K

1 

log Pr(gi|

xi)

−

λ

α

βkj|

|

+ (1

−

α)β2
kj

.



i=1
X

Xk=1

j=1
X

(cid:0)



(cid:1)
(18.21)

The parameter α determines the mix of the penalties, and is often pre-
chosen on qualitative grounds. The elastic net can yield more that N non-
zero coeﬃcients when p > N , a potential advantage over the lasso. Line
(8) in Table 18.1 uses this model, with α and λ chosen by cross-validation.
We used a sequence of 20 values of α between 0.05 and 1.0, and a 100
values of λ uniform on the log scale covering the entire range. Values of
[0.75, 0.80] gave the minimum CV error, with values of λ < 0.001 for all
α
tied solutions. Although it has the lowest test error among all methods, the
margin is small and not signiﬁcant. Interestingly, when CV is performed
separately for each value of α, a minimum test error of 8.8 is achieved at
α = 0.10, but this is not the value chosen in the two-dimensional CV.

∈

r
o
r
r

E
n
o
i
t
a
c
i
f
i
s
s
a
c
s
M

i

l

Training
Test
10−fold CV

4
.
0

3
.
0

2
.
0

1
.
0

0
.
0

e
c
n
a
v
e
D

i

0
3

5
2

0
2

5
1

0
1

5

0

−8

−7

−6

−5

−4

−3

−2

−1

−8

−7

−6

−5

−4

−3

−2

−1

log(λ)

log(λ)

FIGURE 18.6. Training, test, and 10-fold cross validation curves for lasso logis-
tic regression on the leukemia data. The left panel shows misclassiﬁcation errors,
the right panel shows deviance.

Figure 18.5 shows the lasso and elastic-net coeﬃcient paths on the two-
class leukemia data (Golub et al., 1999). There are 7129 gene-expression
measurements on 38 samples, 27 of them in class ALL (acute lymphocytic
leukemia), and 11 in class AML (acute myelogenous leukemia). There is
also a test set with 34 samples (20, 14). Since the data are linearly separa-
ble, the solution is undeﬁned at λ = 0 (Exercise 18.11), and degrades for
very small values of λ. Hence the paths have been truncated as the ﬁtted
probabilities approach 0 and 1. There are 19 non-zero coeﬃcients in the
left plot, and 39 in the right. Figure 18.6 (left panel) shows the misclas-

 
664

18. High-Dimensional Problems: p

N

≫

↓

siﬁcation errors for the lasso logistic regression on the training and test
data, as well as for 10-fold cross-validation on the training data. The right
panel uses binomial deviance to measure errors, and is much smoother. The
small sample sizes lead to considerable sampling variance in these curves,
even though individual curves are relatively smooth (see, for example, Fig-
ure 7.1 on page 220). Both of these plots suggest that the limiting solution
λ
0 is adequate, leading to 3/34 misclassiﬁcations in the test set. The
corresponding ﬁgures for the elastic net are qualitatively similar and are
not shown.
For p

N , the limiting coeﬃcients diverge for all regularized logistic
regression models, so in practical software implementations a minimum
value for λ > 0 is either explicitly or implicitly set. However, renormalized
versions of the coeﬃcients converge, and these limiting solutions can be
thought of as interesting alternatives to the linear optimal separating hy-
perplane (SVM). With α = 0 the limiting solution coincides with the SVM
(see end of Section 18.3.2), but all the 7129 genes are selected. With α = 1,
the limiting solution coincides with an L1 separating hyperplane (Rosset
et al., 2004a), and includes at most 38 genes. As α decreases from 1, the
elastic-net solutions include more genes in the separating hyperplane.

≫

18.4.1 Application of Lasso to Protein Mass Spectroscopy

Protein mass spectrometry has become a popular technology for analyzing
the proteins in blood, and can be used to diagnose a disease or understand
the processes underlying it.

For each blood serum sample i, we observe the intensity xij for many
time of ﬂight values tj. This intensity is related to the number of particles
observed to take approximately tj time to pass from the emitter to the
detector during a cycle of operation of the machine. The time of ﬂight has
a known relationship to the mass over charge ratio (m/z) of the constituent
proteins in the blood. Hence the identiﬁcation of a peak in the spectrum
at a certain tj tells us that there is a protein with a corresponding mass
and charge. The identity of this protein can then be determined by other
means.

Figure 18.7 shows an example taken from Adam et al. (2003). It shows
the average spectra for healthy patients and those with prostate cancer.
There are 16,898 m/z sites in total, ranging in value from 2000 to 40,000.
The full dataset consists of 157 healthy patients and 167 with cancer, and
the goal is to ﬁnd m/z sites that discriminate between the two groups.
This is an example of functional data; the predictors can be viewed as a
function of m/z. There has been much interest in this problem in the past
few years; see e.g. Petricoin et al. (2002).

The data were ﬁrst standardized (baseline subtraction and normaliza-
tion), and we restricted attention to m/z values between 2000 and 40,000
(spectra outside of this range were not of interest). We then applied near-

18.4 Linear Classiﬁers with L1 Regularization

665

Normal
Cancer

y
t
i
s
n
e
n

t

I

0
4

0
3

0
2

0
1

2e+03

5e+03

1e+04

2e+04

5e+04

1e+05

2e+05

m/z

FIGURE 18.7. Protein mass spectrometry data: average proﬁles from normal
and prostate cancer patients.

est shrunken centroids and lasso regression to the data, with the results for
both methods shown in Table 18.2.

By ﬁtting harder to the data, the lasso achieves a considerably lower
test error rate. However, it may not provide a scientiﬁcally useful solu-
tion. Ideally, protein mass spectrometry resolves a biological sample into
its constituent proteins, and these should appear as peaks in the spectra.
The lasso doesn’t treat peaks in any special way, so not surprisingly only
some of the non-zero lasso weights were situated near peaks in the spectra.
Furthermore, the same protein may yield a peak at slightly diﬀerent m/z
values in diﬀerent spectra. In order to identify common peaks, some kind
of m/z warping is needed from sample to sample.

To address this, we applied a standard peak-extraction algorithm to each
spectrum, yielding a total of 5178 peaks in the 217 training spectra. Our
idea was to pool the collection of peaks from all patients, and hence con-
struct a set of common peaks. For this purpose, we applied hierarchical
clustering to the positions of these peaks along the log m/z axis. We cut
the resulting dendrogram horizontally at height log(0.005)3, and computed
averages of the peak positions in each resulting cluster. This process yielded
728 common clusters and their corresponding peak centers.

Given these 728 common peaks, we determined which of these were
present in each individual spectrum, and if present, the height of the peak.
A peak height of zero was assigned if that peak was not found. This pro-
duced a 217
728 matrix of peak heights as features, which was used in a
lasso regression. We scored the test spectra for the same 728 peaks.

×

3Use of the value 0.005 means that peaks with positions less than 0.5% apart are

considered the same peak, a fairly common assumption.

666

18. High-Dimensional Problems: p

N

≫

TABLE 18.2. Results for the prostate data example. The standard deviation for
the test errors is about 4.5.

Method
1. Nearest shrunken centroids
2. Lasso
3. Lasso on peaks

Test Errors/108 Number of Sites
459
113
35

34
22
28

The prediction results for this application of the lasso to the peaks are
shown in the last line of Table 18.2: it does fairly well, but not as well
as the lasso on the raw spectra. However, the ﬁtted model may be more
useful to the biologist as it yields 35 peak positions for further study. On
the other hand, the results suggest that there may be useful discriminatory
information between the peaks of the spectra, and the positions of the lasso
sites from line (2) of the table also deserve further examination.

18.4.2 The Fused Lasso for Functional Data

In the previous example, the features had a natural order, determined by
the mass-to-charge ratio m/z. More generally, we may have functional fea-
tures xi(t) that are ordered according to some index variable t. We have
already discussed several approaches for exploiting such structure.

We can represent xi(t) by their coeﬃcients in a basis of functions in t,
such as splines, wavelets or Fourier bases, and then apply a regression using
these coeﬃcients as predictors. Equivalently, one can instead represent the
coeﬃcients of the original features in these bases. These approaches are
described in Section 5.3.

In the classiﬁcation setting, we discuss the analogous approach of penal-
ized discriminant analysis in Section 12.6. This uses a penalty that explicitly
controls the resulting smoothness of the coeﬃcient vector.

The above methods tend to smooth the coeﬃcients uniformly. Here we
present a more adaptive strategy that modiﬁes the lasso penalty to take
into account the ordering of the features. The fused lasso (Tibshirani et
al., 2005) solves

min
β∈IRp(

N

i=1
X

(yi −

β0 −

p

j=1
X

xijβj)2 + λ1

p

j=1
X

+ λ2

βj|

|

p−1

j=1
X

βj+1 −

|

βj|)

. (18.22)

This criterion is strictly convex in β, so a unique solution exists. The ﬁrst
penalty encourages the solution to be sparse, while the second encourages
it to be smooth in the index j.

The diﬀerence penalty in (18.22) assumes an uniformly spaced index j. If
instead the underlying index variable t has nonuniform values tj, a natural
generalization of (18.22) would be based on divided diﬀerences

18.4 Linear Classiﬁers with L1 Regularization

667

o
i
t
a
r

2
g
o

l

4

2

0

2
−

0

200

400

600

800

1000

Genome order

FIGURE 18.8. Fused lasso applied to CGH data. Each point represents the
copy-number of a gene in a tumor sample, relative to that of a control (on the log
base-2 scale).

p−1

βj+1 −
|
tj+1 −
|
This amounts to having a penalty modiﬁer for each of the terms in the
series.

βj|
tj|

(18.23)

j=1
X

λ2

.

A particularly useful special case arises when the predictor matrix X =
N identity matrix. This is a special case of the fused lasso,
N
1 . The fused lasso signal approximator

IN , the N
used to approximate a sequence
solves

yi}
{

×

N

min
β∈IRN (

(yi −

i=1
X

βi)2 + λ1

β0 −

N

i=1
X

+ λ2

βi|

|

N −1

i=1
X

βi+1 −

|

.

βi|)

(18.24)

Figure 18.8 shows an example taken from Tibshirani and Wang (2007). The
data in the panel come from a Comparative Genomic Hybridization (CGH)
array, measuring the approximate log (base-two) ratio of the number of
copies of each gene in a tumor sample, as compared to a normal sample.
The horizontal axis represents the chromosomal location of each gene. The
idea is that in cancer cells, genes are often ampliﬁed (duplicated) or deleted,
and it is of interest to detect these events. Furthermore, these events tend
to occur in contiguous regions. The smoothed signal estimate from the
fused lasso signal approximator is shown in dark red (with appropriately
chosen values for λ1 and λ2). The signiﬁcantly nonzero regions can be used
to detect locations of gains and losses of genes in the tumor.

There is also a two-dimensional version of the fused lasso, in which the
parameters are laid out in a grid of pixels, and a penalty is applied to the

668

18. High-Dimensional Problems: p

N

≫

ﬁrst diﬀerences to the left, right, above and below the target pixel. This
can be useful for denoising or classifying images. Friedman et al. (2007)
develop fast generalized coordinate descent algorithms for the one- and
two-dimensional fused lasso.

18.5 Classiﬁcation When Features are Unavailable

In some applications the objects under study are more abstract in nature,
and it is not obvious how to deﬁne a feature vector. As long as we can ﬁll
in an N
N proximity matrix of similarities between pairs of objects in our
database, it turns out we can put to use many of the classiﬁers in our arsenal
by interpreting the proximities as inner-products. Protein structures fall
into this category, and we explore an example in Section 18.5.1 below.

×

In other applications, such as document classiﬁcation, feature vectors are
available but can be extremely high-dimensional. Here we may not wish
to compute with such high-dimensional data, but rather store the inner-
products between pairs of documents. Often these inner-products can be
approximated by sampling techniques.

Pairwise distances serve a similar purpose, because they can be turned
into centered inner-products. Proximity matrices are discussed in more de-
tail in Chapter 14.

18.5.1 Example: String Kernels and Protein Classiﬁcation

An important problem in computational biology is to classify proteins into
functional and structural classes based on their sequence similarities. Pro-
tein molecules are strings of amino acids, diﬀering in both length and com-
position. In the example we consider, the lengths vary between 75–160
amino-acid molecules, each of which can be one of 20 diﬀerent types, labeled
using letters. Here are two examples, of length 110 and 153, respectively:

IPTSALVKETLALLSTHRTLLIANETLRIPVPVHKNHQLCTEEIFQGIGTLESQTVQGGTV

ERLFKNLSLIKKYIDGQKKKCGEERRRVNQFLDYLQEFLGVMNTEWI

PHRRDLCSRSIWLARKIRSDLTALTESYVKHQGLWSELTEAERLQENLQAYRTFHVLLA

RLLEDQQVHFTPTEGDFHQAIHTLLLQVAAFAYQIEELMILLEYKIPRNEADGMLFEKK

LWGLKVLQELSQWTVRSIHDLRFISSHQTGIP

There have been many proposals for measuring the similarity between a
pair of protein molecules. Here we focus on a measure based on the count
of matching substrings (Leslie et al., 2004), such as the LQE above.

To construct our features, we count the number of times that a given
sequence of length m occurs in our string, and we compute this number

18.5 Classiﬁcation When Features are Unavailable

669

for all possible sequences of length m. Formally, for a string x, we deﬁne a
feature map

Φm(x) =

φa(x)
{

}a∈Am

(18.25)

where
Am is the set of subsequences of length m, and φa(x) is the number
of times that “a” occurs in our string x. Using this, we deﬁne the inner
product

Km(x1, x2) =

Φm(x1), Φm(x2)

,

i

h

(18.26)

which measures the similarity between the two strings x1, x2. This can be
used to drive, for example, a support vector classiﬁer for classifying strings
into diﬀerent protein classes.

×

|Am|

Now the number of possible sequences a is

= 20m, which can be
very large for moderate m, and the vast majority of the subsequences do
not match the strings in our training set. It turns out that we can compute
N inner-product matrix or string kernel Km (18.26) eﬃciently
the N
using tree-structures, without actually computing the individual vectors.
This methodology, and the data to follow, come from Leslie et al. (2004).4
The data consist of 1708 proteins in two classes— negative (1663) and
positive (45). The two examples above, which we will call “x1” and “x2”,
are from this set. We have marked the occurrences of subsequence LQE,
which appears in both proteins. There are 203 possible subsequences, so
Φ3(x) will be a vector of length 8000. For this example φLQE(x1) = 1 and
φLQE(x2) = 2.

Using software from Leslie et al. (2004), we computed the string kernel
for m = 4, which was then used in a support vector classiﬁer to ﬁnd the
maximal margin solution in this 204 = 160, 000-dimensional feature space.
We used 10-fold cross-validation to compute the SVM predictions on all of
the training data. The orange curve in Figure 18.9 shows the cross-validated
ROC curve for the support vector classiﬁer, computed by varying the cut-
point on the real-valued predictions from the cross-validated support vector
classiﬁer. The area under the curve is 0.84. Leslie et al. (2004) show that
the string kernel method is competitive with, but perhaps not as accurate
as, more specialized methods for protein string matching.

Many other classiﬁers can be computed using only the information in the
kernel matrix; some details are given in the next section. The results for
the nearest centroid classiﬁer (green), and distance-weighted one-nearest
neighbors (blue) are shown in Figure 18.9. Their performance is similar to
that of the support vector classiﬁer.

4We thank Christina Leslie for her help and for providing the data, which is available

on our book website.

670

18. High-Dimensional Problems: p

N

≫

ROC Curves for String Kernel

y
t
i
v
i
t
i
s
n
e
S

0

.

1

8

.

0

6
0

.

4

.

0

2
.
0

0
.
0

SVM  0.84
Nearest Centroid  0.84
One−Nearest Neighbor 0.86

0.0

0.2

0.4

0.6

0.8

1.0

Specificity

FIGURE 18.9. Cross-validated ROC curves for protein example using the string
kernel. The numbers next to each method in the legend give the area under the
curve, an overall measure of accuracy. The SVM achieves better sensitivities than
the other two, which achieve better speciﬁcities.

18.5.2 Classiﬁcation and Other Models Using Inner-Product

Kernels and Pairwise Distances

There are a number of other classiﬁers, besides the support-vector ma-
chine, that can be implemented using only inner-product matrices. This
also implies they can be “kernelized” like the SVM.

An obvious example is nearest-neighbor classiﬁcation, since we can trans-

form pairwise inner-products to pairwise distances:
2 =

xi′ , xi′

xi′

+

xi −

||

||

xi, xii

h

h

2
h

i −

xi, xi′

.

(18.27)

i

A variation of 1-NN classiﬁcation is used in Figure 18.9, which produces
a continuous discriminant score needed to construct a ROC curve. This
distance-weighted 1-NN makes use of the distance of a test points to the
closest member of each class; see Exercise 18.14.

Nearest-centroid classiﬁcation follows easily as well. For training pairs
(xi, gi), i = 1, . . . , N , a test point x0, and class centroids ¯xk, k = 1, . . . , K
we can write

x0 −

¯xk||

||

2 =

x0, x0i −

h

2
Nk

Xgi=k

x0, xii

h

+

1
N 2
k

Xgi=k Xgi′ =k

xi, xi′

h

i

, (18.28)

18.5 Classiﬁcation When Features are Unavailable

671

Hence we can compute the distance of the test point to each of the cen-
troids, and perform nearest centroid classiﬁcation. This also implies that
methods like K-means clustering can also be implemented, using only the
inner products of the data points.

Logistic and multinomial regression with quadratic regularization can
also be implemented with inner-product kernels; see Section 12.3.3 and
Exercise 18.13. Exercise 12.10 derives linear discriminant analysis using an
inner-product kernel.

Principal components can be computed using inner-product kernels as
well; since this is frequently useful, we give some details. Suppose ﬁrst
that we have a centered data matrix X, and let X = UDVT be its SVD
(18.12). Then Z = UD is the matrix of principal component variables (see
Section 14.5.1). But if K = XXT , then it follows that K = UD2UT , and
hence we can compute Z from the eigen decomposition of K. If X is not
centered, then we can center it using ˜X = (I
N 11T
is the mean operator. Thus we compute the eigenvectors of the double-
centered kernel (I
M) for the principal components from an
uncentered inner-product matrix. Exercise 18.15 explores this further, and
Section 14.5.4 discusses in more detail kernel PCA for general kernels, such
as the radial kernel used in SVMs.

M)X, where M = 1

M)K(I

−

−

−

If instead we had available only the pairwise (squared) Euclidean dis-

tances between observations,

∆2

xi −
it turns out we can do all of the above as well. The trick is to convert the
pairwise distances to centered inner-products, and then proceed as before.
We write

(18.29)

ii′ =

xi′

||

||

2,

∆2

ii′ =

||

2

2 +

¯x

¯x

xi′

xi −
∆2

xi −
||
, we double center B:
ii′ /2
}

2
h

−

−

||

||

{−

Deﬁning B =

¯x, xi′

¯x

.

i

−

(18.30)

it is easy to check that ˜Kii′ =
matrix.

h

˜K = (I

M)B(I

M);

−
xi −

−
¯x

−

¯x, xi′

, the centered inner-product

i

(18.31)

Distances and inner-products also allow us to compute the medoid in each
class—the observation with smallest average distance to other observations
in that class. This can be used for classiﬁcation (closest medoids), as well as
to drive k-medoids clustering (Section 14.3.10). With abstract data objects
like proteins, medoids have a practical advantage over means. The medoid is
one of the training examples, and can be displayed. We tried closest medoids
in the example in the next section (see Table 18.3), and its performance is
disappointing.

It is useful to consider what we cannot do with inner-product kernels and

distances:

672

18. High-Dimensional Problems: p

N

≫

TABLE 18.3. Cross-validated error rates for the abstracts example. The nearest
shrunken centroids ended up using no-shrinkage, but does use a word-by-word
standardization (section 18.2). This standardization gives it a distinct advantage
over the other methods.

Method

SVM

1. Nearest shrunken centroids
2.
3. Nearest medoids
4.
5. Nearest centroids

1-NN

CV Error (SE)
0.17 (0.05)
0.23 (0.06)
0.65 (0.07)
0.44 (0.07)
0.29 (0.07)

•

•

•

We cannot standardize the variables; standardization signiﬁcantly im-
proves performance in the example in the next section.

We cannot assess directly the contributions of individual variables.
In particular, we cannot perform individual t-tests, ﬁt the nearest
shrunken centroids model, or ﬁt any model that uses the lasso penalty.

We cannot separate the good variables from the noise: all variables get
an equal say. If, as is often the case, the ratio of relevant to irrelevant
variables is small, methods that use kernels are not likely to work as
well as methods that do feature selection.

18.5.3 Example: Abstracts Classiﬁcation

This somewhat whimsical example serves to illustrate a limitation of ker-
nel approaches. We collected the abstracts from 48 papers, 16 each from
Bradley Efron (BE), Trevor Hastie and Rob Tibshirani (HT) (frequent co-
authors), and Jerome Friedman (JF). We extracted all unique words from
these abstracts, and deﬁned features xij to be the number of times word
j appears in abstract i. This is the so-called bag of words representation.
Quotations, parentheses and special characters were ﬁrst removed from the
abstracts, and all characters were converted to lower case. We also removed
the word “we”, which could unfairly discriminate HT abstracts from the
others.

There were 4492 total words, of which p = 1310 were unique. We sought
to classify the documents into BE, HT or JF on the basis of the features
xij. Although it is artiﬁcial, this example allows us to assess the possible
degradation in performance if information speciﬁc to the raw features is
not used.

We ﬁrst applied the nearest shrunken centroid classiﬁer to the data, using
10-fold cross-validation. It essentially chose no shrinkage, and so used all the
features; see the ﬁrst line of Table 18.3. The error rate is 17%; the number
of features can be reduced to about 500 without much loss in accuracy.

18.5 Classiﬁcation When Features are Unavailable

673

Note that the nearest shrunken classiﬁer requires the raw feature matrix
X in order to standardize the features individually. Figure 18.10 shows the

BE

HT

JF

problems
method
presented
propose
frequentist
bayesian
those
inference
when
variables
accuracy
values
technology
procedure
are
algorithm
than
using
bayes
predictive

FIGURE 18.10. Abstracts example: top 20 scores from nearest shrunken cen-
troids. Each score is the standardized diﬀerence in frequency for the word in the
given class (BE, HT or JF) versus all classes. Thus a positive score (to the right
of the vertical grey zero lines) indicates a higher frequency in that class; a negative
score indicates a lower relative frequency.

top 20 discriminating words, with a positive score indicating that a word
appears more in that class than in the other classes.

Some of these terms make sense: for example “frequentist” and “Bayesian”
reﬂect Efron’s greater emphasis on statistical inference. However, many oth-
ers are surprising, and reﬂect personal writing styles: for example, Fried-
man’s use of “presented” and HT’s use of “propose”.

We then applied the support vector classiﬁer with linear kernel and no
regularization, using the “all pairs” (ovo) method to handle the three
classes (regularization of the SVM did not improve its performance). The
result is shown in Table 18.3. It does somewhat worse than the nearest
shrunken centroid classiﬁer.

As mentioned, the ﬁrst line of Table 18.3 represents nearest shrunken cen-
troids (with no shrinkage). Denote by sj the pooled within-class standard
deviation for feature j, and s0 the median of the sj values. Then line (1)
also corresponds to nearest centroid classiﬁcation, after ﬁrst standardizing
each feature by sj + s0 [recall (18.4) on page 652].

Line (3) shows that the performance of nearest medoids is very poor,
something which surprised us. It is perhaps due to the small sample sizes

674

18. High-Dimensional Problems: p

N

≫

and high dimensions, with medoids having much higher variance than
means. The performance of the one-nearest neighbor classiﬁer is also poor.
The performance of the nearest centroid classiﬁer is also shown in Ta-
ble 18.3 in line (5): it is better than nearest medoids, but worse than that
of nearest shrunken centroids, even with no shrinkage. The diﬀerence seems
to be the standardization of each feature that is done in nearest shrunken
centroids. This standardization is important here, and requires access to
the individual feature values. Nearest centroids uses a spherical metric, and
relies on the fact that the features are in similar units. The support vector
machine estimates a linear combination of the features and can better deal
with unstandardized features.

18.6 High-Dimensional Regression: Supervised

Principal Components

In this section we describe a simple approach to regression and generalized
regression that is especially useful when p
N . We illustrate the method
on another microarray data example. The data is taken from Rosenwald
et al. (2002) and consists of 240 samples from patients with diﬀuse large
B-cell lymphoma (DLBCL), with gene expression measurements for 7399
genes. The outcome is survival time, either observed or right censored. We
randomly divided the lymphoma samples into a training set of size 160 and
a test set of size 80.

≫

Although supervised principal components is useful for linear regression,
its most interesting applications may be in survival studies, which is the
focus of this example.

We have not yet discussed regression with censored survival data in this
book; it represents a generalized form of regression in which the outcome
variable (survival time) is only partly observed for some individuals. Sup-
pose for example we carry out a medical study that lasts for 365 days, and
for simplicity all subjects are recruited on day one. We might observe one
individual to die 200 days after the start of the study. Another individ-
ual might still be alive at 365 days when the study ends. This individual
is said to be “right censored” at 365 days. We know only that he or she
lived at least 365 days. Although we do not know how long past 365 days
the individual actually lived, the censored observation is still informative.
This is illustrated in Figure 18.11. Figure 18.12 shows the survival curve
estimated by the Kaplan–Meier method for the 80 patients in the test set.
See for example Kalbﬂeisch and Prentice (1980) for a description of the
Kaplan–Meier method.

Our objective in this example is to ﬁnd a set of features (genes) that
can predict the survival of an independent set of patients. This could be

18.6 High-Dimensional Regression: Supervised Principal Components

675

t
n
e
i
t
a
P

4

3

2

1

0 

100 

200 

300 

365 

Time(days)

FIGURE 18.11. Censored survival data. For illustration there are four patients.
The ﬁrst and third patients die before the study ends. The second patient is alive
at the end of the study (365 days), while the fourth patient is lost to follow-up
before the study ends. For example, this patient might have moved out of the
country. The survival times for patients two and four are said to be “censored.”

Survival Function

l

l

ll

lll

lll

l

ll

ll

l l

ll

l lllll

l ll

l

l

l

l

0
1

.

8
0

.

6
0

.

4
0

.

2
0

.

0
.
0

)
t

≥

T
(
r
P

0

5

10

15

20

Months t

FIGURE 18.12. Lymphoma data. The Kaplan–Meier estimate of the survival
function for the 80 patients in the test set, along with one-standard-error curves.
The curve estimates the probability of surviving past t months. The ticks indicate
censored observations.

676

18. High-Dimensional Problems: p

N

≫

y
t
i
s
n
e
d

y
t
i
l
i

b
a
b
o
r
p

Poor Cell Type

Good Cell Type

Survival Time

FIGURE 18.13. Underlying conceptual model for supervised principal compo-
nents. There are two cell types, and patients with the good cell type live longer on
the average. Supervised principal components estimate the cell type, by averaging
the expression of genes that reﬂect it.

useful as a prognostic indicator to aid in choosing treatments, or to help
understand the biological basis for the disease.

The underlying conceptual model for supervised principal components
is shown in Figure 18.13. We imagine that there are two cell types, and
patients with the good cell type live longer on the average. However there
is considerable overlap in the two sets of survival times. We might think
of survival time as a “noisy surrogate” for cell type. A fully supervised
approach would give the most weight to those genes having the strongest
relationship with survival. These genes are partially, but not perfectly, re-
lated to cell type. If we could instead discover the underlying cell types of
the patients, often reﬂected by a sizable signature of genes acting together
in pathways, then we might do a better job of predicting patient survival.
Although the cell type in Figure 18.13 is discrete, it is useful to imagine
a continuous cell type, deﬁne by some linear combination of the features.
We will estimate the cell type as a continuous quantity, and then discretize
it for display and interpretation.

How can we ﬁnd the linear combination that deﬁnes the important under-
lying cell types? Principal components analysis (Section 14.5) is an eﬀective
method for ﬁnding linear combinations of features that exhibit large varia-
tion in a dataset. But what we seek here are linear combinations with both
high variance and signiﬁcant correlation with the outcome. The lower right
panel of Figure 18.14 shows the result of applying standard principal com-
ponents in this example; the leading component does not correlate strongly
with survival (details are given in the ﬁgure caption).

Hence we want to encourage principal component analysis to ﬁnd linear
combinations of features that have high correlation with the outcome. To
do this, we restrict attention to features which by themselves have a siz-
able correlation with the outcome. This is summarized in the supervised
principal components Algorithm 18.1, and illustrated in Figure 18.14.

The details in steps (1) and (2b) will depend on the type of outcome
variable. For a standard regression problem, we use the univariate linear
least squares coeﬃcients in step (1) and a linear least squares model in

 
18.6 High-Dimensional Regression: Supervised Principal Components

677

Supervised PC

Best Single Gene

l

i

a
v
v
r
u
S

f
o

y
t
i
l
i

b
a
b
o
r
P

l

i

a
v
v
r
u
S

f
o
y
t
i
l
i

b
a
b
o
r
P

l

i

a
v
v
r
u
S

f
o
y
t
i
l
i

b
a
b
o
r
P

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

0
.
1

8
.
0

6
.
0

4
.
0

2
.
0

0
.
0

low score
high score

P=0.15

0

5

10

15

20

Supervised Principal Component − 27 Genes

P=0.006

0

5

10

15

20

Principal Component − 7399 Genes

P=0.14

1 

27 

s
e
n
e
G

50 

7350 

7399 

1

80

160

0

2

4

0

5

10

15

20

Patients

Absolute Cox Score

Months

FIGURE 18.14. Supervised principal components on the lymphoma data. The
left panel shows a heatmap of a subset of the gene-expression training data. The
rows are ordered by the magnitude of the univariate Cox-score, shown in the mid-
dle vertical column. The top 50 and bottom 50 genes are shown. The supervised
principal component uses the top 27 genes (chosen by 10-fold CV). It is repre-
sented by the bar at the top of the heatmap, and is used to order the columns
of the expression matrix. In addition, each row is multiplied by the sign of the
Cox-score. The middle panel on the right shows the survival curves on the test
data when we create a low and high group by splitting this supervised PC at zero
(training data mean). The curves are well separated, as indicated by the p-value
for the log-rank test. The top panel does the same, using the top-scoring gene on
the training data. The curves are somewhat separated, but not signiﬁcantly. The
bottom panel uses the ﬁrst principal component on all the genes, and the separa-
tion is also poor. Each of the top genes can be interpreted as noisy surrogates for
a latent underlying cell-type characteristic, and supervised principal components
uses them all to estimate this latent factor.

 
 
 
 
 
 
678

18. High-Dimensional Problems: p

N

≫

Algorithm 18.1 Supervised Principal Components.

1. Compute the standardized univariate regression coeﬃcients for the

outcome as a function of each feature separately.

2. For each value of the threshold θ from the list 0

θ1 < θ2 <

< θK:

· · ·

≤

(a) Form a reduced data matrix consisting of only those features
whose univariate coeﬃcient exceeds θ in absolute value, and
compute the ﬁrst m principal components of this matrix.

(b) Use these principal components in a regression model to predict

the outcome.

3. Pick θ (and m) by cross-validation.

step (2b). For survival problems, Cox’s proportional hazards regression
model is widely used; hence we use the score test from this model in step (1)
and the multivariate Cox model in step (2b). The details are not essential
for understanding the basic method; they may be found in Bair et al. (2006).
Figure 18.14 shows the results of supervised principal components in this
example. We used a Cox-score cutoﬀ of 3.53, yielding 27 genes, where the
value 3.53 was found through 10-fold cross-validation. We then computed
the ﬁrst principal component (m = 1) using just this subset of the data,
as well as its value for each of the test observations. We included this as
a quantitative predictor in a Cox regression model, and its likelihood-ratio
signiﬁcance was p = 0.005. When dichotomized (using the mean score on
the training data as a threshold), it clearly separates the patients in the
test set into low and high risk groups (middle-right panel of Figure 18.14,
p = 0.006).

The top-right panel of Figure 18.14 uses the top scoring gene (dichot-
omized) alone as a predictor of survival. It is not signiﬁcant on the test set.
Likewise, the lower-right panel shows the dichotomized principal compo-
nent using all the training data, which is also not signiﬁcant.

Our procedure allows m > 1 principal components in step (2a). However,
the supervision in step (1) encourages the principal components to align
with the outcome, and thus in most cases only the ﬁrst or ﬁrst few com-
ponents tend to be useful for prediction. In the mathematical development
below, we consider only the ﬁrst component, but extensions to more than
one component can be derived in a similar way.

18.6.1 Connection to Latent-Variable Modeling

A formal connection between supervised principal components and the un-
derlying cell type model (Figure 18.13) can be seen through a latent variable
model for the data. Suppose we have a response variable Y which is related

18.6 High-Dimensional Regression: Supervised Principal Components

679

to an underlying latent variable U by a linear model

Y = β0 + β1U + ε.

(18.32)

In addition, we have measurements on a set of features Xj indexed by j
(for pathway), for which

∈ P

Xj = α0j + α1jU + ǫj,

j

.

∈ P

(18.33)

The errors ε and ǫj are assumed to have mean zero and are independent of
all other random variables in their respective models.

We also have many additional features Xk, k

which are independent
of U . We would like to identify
, estimate U , and hence ﬁt the predic-
tion model (18.32). This is a special case of a latent-structure model, or
single-component factor-analysis model (Mardia et al., 1979, see also Sec-
tion 14.7). The latent factor U is a continuous version of the cell type
conceptualized in Figure 18.13.

6∈ P

P

The supervised principal component algorithm can be seen as a method

for ﬁtting this model:

The screening step (1) estimates the set

.

P

, the largest principal component in step (2a) estimates the

Finally, the regression ﬁt in step (2b) estimates the coeﬃcient in
model (18.32).

Step (1) is natural, since on average the regression coeﬃcient is nonzero
only if α1j is non-zero. Hence this step should select the features j
.
∈ P
Step (2a) is natural if we assume that the errors ǫj have a Gaussian dis-
tribution, with the same variance. In this case the principal component is
the maximum likelihood estimate for the single factor model (Mardia et
al., 1979). The regression in (2b) is an obvious ﬁnal step.

Suppose there are a total of p features, with p1 features in the relevant set
. Then if p and p1 grow but p1 is small relative to p, one can show (under
P
reasonable conditions) that the leading supervised principal component
is consistent for the underlying latent factor. The usual leading principal
component may not be consistent, since it can be contaminated by the
presence of a large number of “noise” features.

Finally, suppose that the threshold used in step (1) of the supervised
principal component procedure yields a large number of features for com-
putation of the principal component. Then for interpretational purposes, as
well as for practical uses, we would like some way of ﬁnding a reduced a set
of features that approximates the model. Pre-conditioning (Section 18.6.3)
is one way of doing this.

•

•

•

Given
P
latent factor U .
b

680

18. High-Dimensional Problems: p

N

≫

18.6.2 Relationship with Partial Least Squares

Supervised principal components is closely related to partial least squares
regression (Section 3.5.2). Bair et al. (2006) found that the key to the good
performance of supervised principal components was the ﬁltering out of
noisy features in step (2a). Partial least squares (Section 3.5.2) downweights
noisy features, but does not throw them away; as a result a large number
of noisy features can contaminate the predictions. However, a modiﬁcation
of the partial least squares procedure has been proposed that has a similar
ﬂavor to supervised principal components [Brown et al. (1991),Nadler and
Coifman (2005), for example]. We select the features as in steps (1) and
(2a) of supervised principal components, but then apply PLS (rather than
principal components) to these features. For our current discussion, we call
this “thresholded PLS.”

Thresholded PLS can be viewed as a noisy version of supervised principal
components, and hence we might not expect it to work as well in practice.
Assume the variables are all standardized. The ﬁrst PLS variate has the
form

z =

Xj∈P

y, xji

h

xj,

(18.34)

and can be thought of as an estimate of the latent factor U in model (18.33).
In contrast, the supervised principal components direction ˆu satisﬁes

ˆu =

1
d2

ˆu, xji

h

xj,

Xj∈P

(18.35)

where d is the leading singular value of XP . This follows from the deﬁnition
of the leading principal component. Hence thresholded PLS uses weights
which are the inner product of y with each of the features, while supervised
principal components uses the features to derive a “self-consistent” estimate
ˆu. Since many features contribute to the estimate ˆu, rather than just the
single outcome y, we can expect ˆu to be less noisy than z. In fact, if there
are p1 features in the set
0,
, and N, p and p1 go to inﬁnity with p1/N
then it can be shown using the techniques in Bair et al. (2006) that

→

P

z = u + Op(1)
ˆu = u + Op(

p1/N ),

(18.36)

where u is the true (unobservable) latent variable in the model (18.32),
(18.33).

p

We now present a simulation example to compare the methods numeri-
cally. There are N = 100 samples and p = 5000 genes. We generated the
data as follows:

18.6 High-Dimensional Regression: Supervised Principal Components

681

FIGURE 18.15. Heatmap of the outcome (left column) and ﬁrst 500 genes from
a realization from model (18.37). The genes are in the columns, and the samples
are in the rows.

xij =

(

xij =

(
xij = ǫij
yi = 2

3 + ǫij
4 + ǫij
1.5 + ǫij
5.5 + ǫij

if i
50,
≤
if i > 50

i

if 1
if 26

≤

≤

·

1
50

50
j=1 xij + εi

P

25 or 51

i

75

50 or 76

≤
≤

≤
i
≤

100

≤
i
≤

j = 1, . . . , 50

j = 51, . . . , 250

j = 251, . . . , 5000

(18.37)

where ǫij and εi are independent normal random variables with mean 0 and
standard deviations 1 and 1.5, respectively. Thus in the ﬁrst 50 genes, there
is an average diﬀerence of 1 unit between samples 1–50 and 51–100, and this
diﬀerence correlates with the outcome y. The next 200 genes have a large
average diﬀerence of 4 units between samples (1–25, 51–75) and (26–50,
76–100), but this diﬀerence is uncorrelated with the outcome. The rest of
the genes are noise. Figure 18.15 shows a heatmap of a typical realization,
with the outcome at the left, and the ﬁrst 500 genes to the right.

We generated 100 simulations from this model, and summarize the test
error results in Figure 18.16. The test errors of principal components and
partial least squares are shown at the right of the plot; both are badly
aﬀected by the noisy features in the data. Supervised principal components
and thresholded PLS work best over a wide range of the number of selected
features, with the former showing consistently lower test errors.

While this example seems “tailor-made” for supervised principal com-
ponents, its good performance seems to hold in other simulated and real
datasets (Bair et al., 2006).

18.6.3 Pre-Conditioning for Feature Selection

Supervised principal components can yield lower test errors than competing
methods, as shown in Figure 18.16. However, it does not always produce a
sparse model involving only a small number of features (genes). Even if the
thresholding in Step (1) of the algorithm yields a relatively small number

682

18. High-Dimensional Problems: p

N

≫

r
o
r
r

E

t
s
e
T
e
r
a
u
q
S
n
a
e
M

t

o
o
R
e
v
i
t

l

a
e
R

Thresholded PLS
Supervised Principal Components

5
2

.

1

0
2
1

.

5
1
1

.

0
1

.

1

5
0
1

.

0
0
1

.

0

50

100

150

200

250

300

...

5000

Number of Features

FIGURE 18.16. Root mean squared test error (
one standard error), for
supervised principal components and thresholded PLS on 100 realizations from
model (18.37). All methods use one component, and the errors are relative to
the noise standard deviation (the Bayes error is 1.0). For both methods, diﬀerent
values for the ﬁltering threshold were tried and the number of features retained
is shown on the horizontal axis. The extreme right points correspond to regular
principal components and partial least squares, using all the genes.

±

of features, it may be that some of the omitted features have sizable inner
products with the supervised principal component (and could act as a good
surrogate). In addition, highly correlated features will tend to be chosen
together, and there may be great deal of redundancy in the set of selected
features.

The lasso (Sections 18.4 and 3.4.2), on the other hand, produces a sparse
model from the data. How do the test errors of the two methods compare on
the simulated example of the last section? Figure 18.17 shows the test errors
for one realization from model (18.37) for the lasso, supervised principal
components, and the pre-conditioned lasso (described below).

We see that supervised principal components (orange curve) reaches its
lowest error when about 50 features are included in the model, which is
the correct number for the simulation. Although a linear model in the ﬁrst
50 features is optimal, the lasso (green) is adversely aﬀected by the large
number of noisy features, and starts overﬁtting when far fewer are in the
model.

Can we get the low test error of supervised principal components along
with the sparsity of the lasso? This is the goal of pre-conditioning (Paul
et al., 2008). In this approach, one ﬁrst computes the supervised principal
component predictor ˆyi for each observation in the training set (with the

 
 
 
 
 
18.7 Feature Assessment and the Multiple-Testing Problem

683

Lasso
Supervised Principal Components
Preconditioned Lasso

r
o
r
r

E

t
s
e
T
n
a
e
M

4

.

4

2
4

.

0

.

4

8
3

.

6
3

.

4
3

.

2
3

.

0
3

.

0

50

100

150

200

250

Number of Features in Model

FIGURE 18.17. Test errors for the lasso, supervised principal components,
and pre-conditioned lasso, for one realization from model (18.37). Each model is
indexed by the number of non-zero features. The supervised principal component
path is truncated at 250 features. The lasso self-truncates at 100, the sample size
(see Section 18.4). In this case, the pre-conditioned lasso achieves the lowest error
with about 25 features.

threshold selected by cross-validation). Then we apply the lasso with ˆyi as
the outcome variable, in place of the usual outcome yi. All features are used
in the lasso ﬁt, not just those that were retained in the thresholding step
in supervised principal components. The idea is that by ﬁrst denoising the
outcome variable, the lasso should not be as adversely aﬀected by the large
number of noise features. Figure 18.17 shows that pre-conditioning (purple
curve) has been successful here, yielding much lower test error than the
usual lasso, and as low (in this case) as for supervised principal components.
It also can achieve this using less features. The usual lasso, applied to
the raw outcome, starts to overﬁt more quickly than the pre-conditioned
version. Overﬁtting is not a problem, since the outcome variable has been
denoised. We usually select the tuning parameter for the pre-conditioned
lasso on more subjective grounds, like parsimony.

Pre-conditioning can be applied in a variety of settings, using initial
estimates other than supervised principal components and post-processors
other than the lasso. More details may be found in Paul et al. (2008).

18.7 Feature Assessment and the Multiple-Testing

Problem

N
In the ﬁrst part of this chapter we discuss prediction models in the p
setting. Here we consider the more basic problem of assessing the signif-

≫

 
 
684

18. High-Dimensional Problems: p

N

≫

icance of each of the p features. Consider the protein mass spectrometry
example of Section 18.4.1. In that problem, the scientist might not be inter-
ested in predicting whether a given patient has prostate cancer. Rather the
goal might be to identify proteins whose abundance diﬀers between nor-
mal and cancer samples, in order to enhance understanding of the disease
and suggest targets for drug development. Thus our goal is to assess the
signiﬁcance of individual features. This assessment is usually done without
the use of a multivariate predictive model like those in the ﬁrst part of this
chapter. The feature assessment problem moves our focus from prediction
to the traditional statistical topic of multiple hypothesis testing. For the
remainder of this chapter we will use M instead of p to denote the number
of features, since we will frequently be referring to p-values.

TABLE 18.4. Subset of the 12, 625 genes from microarray study of radiation
sensitivity. There are a total of 44 samples in the normal group and 14 in the
radiation sensitive group; we only show three samples from each group.

Gene 1
Gene 2
Gene 3
Gene 4
...
Gene 12,625

7.85
15.44
-1.79
-11.74
...
-14.09

Normal

29.74
2.70
15.52
22.35
...
32.77

29.50
19.37
-3.13
-36.11
...
57.78

. . .
. . .
. . .
. . .
...
. . .

Radiation Sensitive
-18.89
79.18
4.75
-2.32
...
-101.44

-50.75
-7.41
12.64
7.24
...
24.09

17.20
6.57
-8.32
-52.17
...
-32.84

. . .
. . .
. . .
. . .
...
. . .

Consider, for example, the microarray data in Table 18.4, taken from a
study on the sensitivity of cancer patients to ionizing radiation treatment
(Rieger et al., 2004). Each row consists of the expression of genes in 58
patient samples: 44 samples were from patients with a normal reaction, and
14 from patients who had a severe reaction to radiation. The measurements
were made on oligo-nucleotide microarrays. The object of the experiment
was to ﬁnd genes whose expression was diﬀerent in the radiation sensitive
group of patients. There are M = 12, 625 genes altogether; the table shows
the data for some of the genes and samples for illustration.

To identify informative genes, we construct a two-sample t-statistic for

each gene.

tj =

¯x2j −
sej

¯x1j

,

(18.38)

where ¯xkj =
xij/Nℓ. Here Cℓ are the indices of the Nℓ samples in
group ℓ, where ℓ = 1 is the normal group and ℓ = 2 is the sensitive group.
The quantity sej is the pooled within-group standard error for gene j:

i∈Cℓ

P

18.7 Feature Assessment and the Multiple-Testing Problem

685

0
0
8

0
0
6

0
0
4

0
0
2

0

−4

−2

0

2

4

t−statistics

FIGURE 18.18. Radiation sensitivity microarray example. A histogram of the
12, 625 t-statistics comparing the radiation-sensitive versus insensitive groups.
Overlaid in blue is the histogram of the t-statistics from 1000 permutations of the
sample labels.

sej = ˆσj

1
N1

+ 1
N2

; ˆσ2

j =

1
N1+N2−2

(xij −

¯x1j)2 +

(xij −

¯x2j)2

.

−

q

Xi∈C2

Xi∈C1

!
(18.39)
A histogram of the 12,625 t-statistics is shown in orange in Figure 18.18,
ranging in value from
4.7 to 5.0. If the tj values were normally distributed
we could consider any value greater than two in absolute value to be sig-
niﬁcantly large. This would correspond to a signiﬁcance level of about 5%.
Here there are 1189 genes with
2. However with 12,625 genes we
tj| ≥
would expect many large values to occur by chance, even if the group-
ing is unrelated to any gene. For example, if the genes were independent
(which they are surely not), the number of falsely signiﬁcant genes would
have a binomial distribution with mean 12, 625
0.05 = 631.3 and standard
deviation 24.5; the actual 1189 is way out of range.

|

·

How do we assess the results for all 12,625 genes? This is called the mul-
tiple testing problem. We can start as above by computing a p-value for
each gene. This can be done using the theoretical t-distribution probabil-
ities, which assumes the features are normally distributed. An attractive
alternative approach is to use the permutation distribution, since it avoids
assumptions about the distribution of the data. We compute (in principle)
all K =
permutations of the sample labels, and for each permutation
k compute the t-statistics tk
j . Then the p-value for gene j is

58
14

(cid:0)

(cid:1)

 
686

18. High-Dimensional Problems: p

N

≫

pj =

1
K

K

Xk=1

I(

tk
j |

|

>

).

tj|

|

(18.40)

58
14

is a large number (around 1013) and so we can’t enumer-
Of course,
ate all of the possible permutations. Instead we take a random sample of
the possible permutations; here we took a random sample of K = 1000
permutations.

(cid:1)

(cid:0)

To exploit the fact that the genes are similar (e.g., measured on the
same scale), we can instead pool the results for all genes in computing the
p-values.

pj =

1
M K

M

K

Xj′=1

Xk=1

I(

tk
j′

|

|

>

).

tj|

|

(18.41)

This also gives more granular p-values than does (18.40), since there many
more values in the pooled null distribution than there are in each individual
null distribution.

Using this set of p-values, we would like to test the hypotheses:

H0j = treatment has no eﬀect on gene j

versus

(18.42)

H1j = treatment has an eﬀect on gene j

for all j = 1, 2, . . . , M . We reject H0j at level α if pj < α. This test has
type-I error equal to α; that is, the probability of falsely rejecting H0j is α.
Now with many tests to consider, it is not clear what we should use
as an overall measure of error. Let Aj be the event that H0j is falsely
rejected; by deﬁnition Pr(Aj) = α. The family-wise error rate (FWER)
is the probability of at least one false rejection, and is a commonly used
M
j=1Aj is the event of at least
overall measure of error. In detail, if A =
one false rejection, then the FWER is Pr(A). Generally Pr(A)
α for
large M , and depends on the correlation between the tests. If the tests are
independent each with type-I error rate α, then the family-wise error rate
α)M ). On the other hand, if the tests
of the collection of tests is (1
Ak) > Pr(Aj), then the FWER
have positive dependence, that is Pr(Aj|
α)M ). Positive dependence between tests often
will be less than (1
−
−
occurs in practice, in particular in genomic studies.

≫

(1

(1

−

−

∪

One of the simplest approaches to multiple testing is the Bonferroni
method. It makes each individual test more stringent, in order to make the
FWER equal to at most α: we reject H0j if pj < α/M . It is easy to show
α (Exercise 18.16). The Bonferroni method
that the resulting FWER is
can be useful if M is relatively small, but for large M it is too conservative,
that is, it calls too few genes signiﬁcant.

≤

In our example, if we test at level say α = 0.05, then we must use the
10−6. None of the 12, 625 genes had a p-value

threshold 0.05/12, 625 = 3.9
this small.

×

18.7 Feature Assessment and the Multiple-Testing Problem

687

There are variations to this approach that adjust the individual p-values
to achieve an FWER of at most α, with some approaches avoiding the
assumption of independence; see, e.g., Dudoit et al. (2002b).

18.7.1 The False Discovery Rate

A diﬀerent approach to multiple testing does not try to control the FWER,
but focuses instead on the proportion of falsely signiﬁcant genes. As we will
see, this approach has a strong practical appeal.

Table 18.5 summarizes the theoretical outcomes of M hypothesis tests.
1). Here we instead focus

Note that the family-wise error rate is Pr(V

≥

TABLE 18.5. Possible outcomes from M hypothesis tests. Note that V is the
number of false-positive tests; the type-I error rate is E(V )/M0. The type-II error
rate is E(T )/M1, and the power is 1

E(T )/M1.

−
Called
Not Signiﬁcant
U
T

M

R

−

Called

Signiﬁcant Total
M0
M1
M

V
S
R

H0 True
H0 False
Total

on the false discovery rate

FDR = E(V /R).

(18.43)

In the microarray setting, this is the expected proportion of genes that
are incorrectly called signiﬁcant, among the R genes that are called signif-
icant. The expectation is taken over the population from which the data
are generated. Benjamini and Hochberg (1995) ﬁrst proposed the notion of
false discovery rate, and gave a testing procedure (Algorithm 18.2) whose
FDR is bounded by a user-deﬁned level α. The Benjamini–Hochberg (BH)
procedure is based on p-values; these can be obtained from an asymptotic
approximation to the test statistic (e.g., Gaussian), or a permutation dis-
tribution, as is done here.

If the hypotheses are independent, Benjamini and Hochberg (1995) show
that regardless of how many null hypotheses are true and regardless of the
distribution of the p-values when the null hypothesis is false, this procedure
has the property

FDR

M0
M

α

α.

≤

≤

(18.45)

For illustration we chose α = 0.15. Figure 18.19 shows a plot of the or-

dered p-values p(j), and the line with slope 0.15/12625.

688

18. High-Dimensional Problems: p

N

≫

Algorithm 18.2 Benjamini–Hochberg (BH) Method.
1. Fix the false discovery rate α and let p(1) ≤

the ordered p-values

p(2) ≤ · · · ≤

p(M ) denote

2. Deﬁne

L = max

j : p(j) < α

j
M

·

o
3. Reject all hypotheses H0j for which pj ≤

n

threshold.

.

(18.44)

p(L), the BH rejection

l

e
u
a
v
−
p

3
−
^
0
1
*
5

4
−
^
0
1
*
5

5
−
^
0
1
*
5

6
−
^
0
1
*
5

•

1

•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

••••••••
•
••

• • •

•

• •

•

5

10

50

100

Genes ordered by p−value

FIGURE 18.19. Microarray example continued. Shown is a plot of the ordered
p-values p(j) and the line 0.15
(j/12, 625), for the Benjamini–Hochberg method.
The largest j for which the p-value p(j) falls below the line, gives the BH threshold.
Here this occurs at j = 11, indicated by the vertical line. Thus the BH method
calls signiﬁcant the 11 genes (in red) with smallest p-values.

·

18.7 Feature Assessment and the Multiple-Testing Problem

689

Algorithm 18.3 The Plug-in Estimate of the False Discovery Rate.

1. Create K permutations of the data, producing t-statistics tk
tures j = 1, 2, . . . , M and permutations k = 1, 2, . . . , K.

j for fea-

2. For a range of values of the cut-point C, let

Robs =

M

j=1
X

I(

tj|

|

> C),

[
E(V ) =

1
K

M

K

j=1
X

Xk=1

I(

tk
j |

|

> C).

(18.46)

3. Estimate the FDR by [FDR =

[
E(V )/Robs.

Starting at the left and moving right, the BH method ﬁnds the last time
that the p-values fall below the line. This occurs at j = 11, so we reject
the 11 genes with smallest p-values. Note that the cutoﬀ occurs at the 11th
smallest p-value, 0.00012, and the 11th largest of the values
is 4.101
Thus we reject the 11 genes with

tj| ≥
From our brief description, it is not clear how the BH procedure works;
that is, why the corresponding FDR is at most 0.15, the value used for α.
Indeed, the proof of this fact is quite complicated (Benjamini and Hochberg,
1995).

4.101.

tj|

|

|

A more direct way to proceed is a plug-in approach. Rather than starting
with a value for α, we ﬁx a cut-point for our t-statistics, say the value
equal or
4.101 that appeared above. The number of observed values
tj|
tk
greater than 4.101 is 11. The total number of permutation values
equal
j |
or greater than 4.101 is 1518, for an average of 1518/1000 = 1.518 per
permutation. Thus a direct estimate of the false discovery rate is [FDR =
1.518/11
14%. Note that 14% is approximately equal to the value of
α = 0.15 used above (the diﬀerence is due to discreteness). This procedure
is summarized in Algorithm 18.3. To recap:

≈

|

|

The plug-in estimate of FDR of Algorithm 18.3 is equivalent to the BH
procedure of Algorithm 18.2, using the permutation p-values (18.40).

This correspondence between the BH method and the plug-in estimate is
not a coincidence. Exercise 18.17 shows that they are equivalent in general.
Note that this procedure makes no reference to p-values at all, but rather
works directly with the test statistics.

The plug-in estimate is based on the approximation

E(V /R)

E(V )
E(R)

,

≈
and in general [FDR is a consistent estimate of FDR (Storey, 2002; Storey et
[
E(V ) actually estimates (M/M0)E(V ),
al., 2004). Note that the numerator

(18.47)

690

18. High-Dimensional Problems: p

N

≫

since the permutation distribution uses M rather M0 null hypotheses.
Hence if an estimate of M0 is available, a better estimate of FDR can be
[FDR. Exercise 18.19 shows a way to estimate M0.
obtained from ( ˆM0/M )
The most conservative (upwardly biased) estimate of FDR uses M0 = M .
Equivalently, an estimate of M0 can be used to improve the BH method,
through relation (18.45).

·

The reader might be surprised that we chose a value as large as 0.15 for
α, the FDR bound. We must remember that the FDR is not the same as
type-I error, for which 0.05 is the customary choice. For the scientist, the
false discovery rate is the expected proportion of false positive genes among
the list of genes that the statistician tells him are signiﬁcant. Microarray
experiments with FDRs as high as 0.15 might still be useful, especially if
they are exploratory in nature.

18.7.2 Asymmetric Cutpoints and the SAM Procedure

In the testing methods described above, we used the absolute value of the
test statistic tj, and hence applied the same cut-points to both positive and
negative values of the statistic. In some experiments, it might happen that
most or all of the diﬀerentially expressed genes change in the positive direc-
tion (or all in the negative direction). For this situation it is advantageous
to derive separate cut-points for the two cases.

K
k=1 tk

The signiﬁcance analysis of microarrays (SAM) approach oﬀers a way of
doing this. The basis of the SAM method is shown in Figure 18.20. On the
t(2) ≤ · · · ≤
vertical axis we have plotted the ordered test statistics t(1) ≤
t(M ), while the horizontal axis shows the expected order statistics from the
permutations of the data: ˜t(j) = (1/K)
tk
(2) ≤ · · · ≤
tk
(M ) are the ordered test statistics from permutation k.

(j), where tk

Two lines are drawn, parallel to the 45◦ line, ∆ units away. Starting at
the origin and moving to the right, we ﬁnd the ﬁrst place that the genes
leave the band. This deﬁnes the upper cutpoint Chi and all genes beyond
that point are called signiﬁcant (marked red). Similarly we ﬁnd the lower
cutpoint Clow for genes in the bottom left corner. Thus each value of the
tuning parameter ∆ deﬁnes upper and lower cutpoints, and the plug-in
estimate [FDR for each of these cutpoints is estimated as before. Typically
a range of values of ∆ and associated [FDR values are computed, from which
a particular pair are chosen on subjective grounds.

(1) ≤

P

The advantage of the SAM approach lies in the possible asymmetry of
the cutpoints. In the example of Figure 18.20, with ∆ = 0.71 we obtain
11 signiﬁcant genes; they are all in the upper right. The data points in the
bottom left never leave the band, and hence Clow =
. Hence for this
value of ∆, no genes are called signiﬁcant on the left (negative) side. We
do not impose symmetry on the cutpoints, as was done in Section 18.7.1,
as there is no reason to assume similar behavior at the two ends.

−∞

18.7 Feature Assessment and the Multiple-Testing Problem

691

c
i
t
s
i
t
a
t
s
−

t

4

2

0

2
−

4
−

•
•

•
•

∆

•••••
•••••
•••••

Chi

•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

•••

•

−4

−2

0

2

4

Expected Order Statistics

FIGURE 18.20. SAM plot for the radiation sensitivity microarray data. On the
vertical axis we have plotted the ordered test statistics, while the horizontal axis
shows the expected order statistics of the test statistics from permutations of the
data. Two lines are drawn, parallel to the 45◦ line, ∆ units away from it. Starting
at the origin and moving to the right, we ﬁnd the ﬁrst place that the genes leave
the band. This deﬁnes the upper cut-point Chi and all genes beyond that point are
called signiﬁcant (marked in red). Similarly we deﬁne a lower cutpoint Clow. For
the particular value of ∆ = 0.71 in the plot, no genes are called signiﬁcant in the
bottom left.

692

18. High-Dimensional Problems: p

N

≫

There is some similarity between this approach and the asymmetry possi-
ble with likelihood-ratio tests. Suppose we have a log-likelihood ℓ0(tj) under
the null-hypothesis of no eﬀect, and a log-likelihood ℓ(tj) under the alterna-
tive. Then a likelihood ratio test amounts to rejecting the null-hypothesis
if

ℓ(tj)

−

ℓ0(tj) > ∆,

(18.48)

for some ∆. Depending on the likelihoods, and particularly their relative
values, this can result in a diﬀerent threshold for tj than for
tj. The SAM
procedure rejects the null-hypothesis if

−

˜t(j)|
Again, the threshold for each t(j) depends on the corresponding value of
the null value ˜t(j).

t(j) −

(18.49)

> ∆

|

18.7.3 A Bayesian Interpretation of the FDR

There is an interesting Bayesian view of the FDR, developed in Storey
(2002) and Efron and Tibshirani (2002). First we need to deﬁne the positive
false discovery rate (pFDR) as

pFDR = E

V
R

(cid:20)

R > 0

.

(cid:21)

(18.50)

(cid:12)
(cid:12)
(cid:12)
(cid:12)

The additional term positive refers to the fact that we are only interested
in estimating an error rate where positive ﬁndings have occurred. It is
this slightly modiﬁed version of the FDR that has a clean Bayesian inter-
pretation. Note that the usual FDR [expression (18.43)] is not deﬁned if
Pr(R = 0) > 0.

,

−

−∞

4.10)

(4.10,

Let Γ be a rejection region for a single test; in the example above we used
). Suppose that M identical simple hypothe-
Γ = (
sis tests are performed with the i.i.d. statistics t1, . . . , tM and rejection
region Γ. We deﬁne a random variable Zj which equals 0 if the jth null
hypothesis is true, and 1 otherwise. We assume that each pair (tj, Zj) are
i.i.d random variables with

∞

∪

tj|

Zj ∼

(1

−

Zj)

F0 + Zj ·

·

F1

(18.51)

for some distributions F0 and F1. This says that each test statistic tj comes
from one of two distributions: F0 if the null hypothesis is true, and F1
otherwise. Letting Pr(Zj = 0) = π0, marginally we have:

tj ∼

π0 ·

F0 + (1

π0)

F1.

·

−

(18.52)

Then it can be shown (Efron et al., 2001; Storey, 2002) that

18.8 Bibliographic Notes

693

pFDR(Γ) = Pr(Zj = 0
|

tj ∈

Γ).

(18.53)

Hence under the mixture model (18.51), the pFDR is the posterior proba-
bility that the null hypothesis it true, given that test statistic falls in the
rejection region for the test; that is, given that we reject the null hypothesis
(Exercise 18.20).

The false discovery rate provides a measure of accuracy for tests based
on an entire rejection region, such as
2. But if the FDR of such a test
tj| ≥
|
is say 10%, then a gene with say tj = 5 will be more signiﬁcant than a gene
with tj = 2. Thus it is of interest to derive a local (gene-speciﬁc) version
of the FDR. The q-value (Storey, 2003) of a test statistic tj is deﬁned to
be the smallest FDR over all rejection regions that reject tj. That is, for
symmetric rejection regions, the q-value for tj = 2 is deﬁned to be the
FDR for the rejection region Γ =
. Thus the q-value
(
}
{−
for tj = 5 will be smaller than that for tj = 2, reﬂecting the fact that tj = 5
is more signiﬁcant than tj = 2. The local false discovery rate (Efron and
Tibshirani, 2002) at t = t0 is deﬁned to be

(2,

∞

∞

2)

−

∪

)

,

Pr(Zj = 0
|

tj = t0).

(18.54)

This is the (positive) FDR for an inﬁnitesimal rejection region surrounding
the value tj = t0.

18.8 Bibliographic Notes

→ ∞

Many references were given at speciﬁc points in this chapter; we give some
additional ones here. Dudoit et al. (2002a) give an overview and compar-
ison of discrimination methods for gene expression data. Levina (2002)
does some mathematical analysis comparing diagonal LDA to full LDA, as
with p > N . She shows that with reasonable assumptions diago-
p, N
nal LDA has a lower asymptotic error rate than full LDA. Tibshirani et al.
(2001a) and Tibshirani et al. (2003) proposed the nearest shrunken-centroid
classiﬁer. Zhu and Hastie (2004) study regularized logistic regression. High-
dimensional regression and the lasso are very active areas of research, and
many references are given in Section 3.8.5. The fused lasso was proposed
by Tibshirani et al. (2005), while Zou and Hastie (2005) introduced the
elastic net. Supervised principal components is discussed in Bair and Tib-
shirani (2004) and Bair et al. (2006). For an introduction to the analysis
of censored survival data, see Kalbﬂeisch and Prentice (1980).

Microarray technology has led to a ﬂurry of statistical research: see for
example the books by Speed (2003), Parmigiani et al. (2003), Simon et al.
(2004), and Lee (2004).

The false discovery rate was proposed by Benjamini and Hochberg (1995),
and studied and generalized in subsequent papers by these authors and

694

18. High-Dimensional Problems: p

N

≫

many others. A partial list of papers on FDR may be found on Yoav Ben-
jamini’s homepage. Some more recent papers include Efron and Tibshirani
(2002), Storey (2002), Genovese and Wasserman (2004), Storey and Tib-
shirani (2003) and Benjamini and Yekutieli (2005). Dudoit et al. (2002b)
review methods for identifying diﬀerentially expressed genes in microarray
studies.

Exercises

Ex. 18.1 For a coeﬃcient estimate ˆβj, let ˆβj/
ˆβj||2 be the normalized ver-
||
sion. Show that as λ
, the normalized ridge-regression estimates con-
verge to the renormalized partial-least-squares one-component estimates.

→ ∞

Ex. 18.2 Nearest shrunken centroids and the lasso. Consider a (naive Bayes)
Gaussian model for classiﬁcation in which the features j = 1, 2, . . . , p are
assumed to be independent within each class k = 1, 2, . . . , K. With ob-
servations i = 1, 2, . . . , N and Ck equal to the set of indices of the Nk
N (µj + µjk, σ2
Ck with
observations in class k, we observe xij ∼
j , the pooled within-class variance for feature j,

K
k=1 µjk = 0. Set ˆσ2

j = s2
and consider the lasso-style minimization problem
P

j ) for i

∈

1
2

min

{µj ,µjk} 


p

K

j=1
X

Xk=1 Xi∈Ck

(xij −

µj −
s2
j

µjk)2

p

K

+ λ

Nk

p

j=1
X

Xk=1

|

µjk|
sj

.

(18.55)






1/N as before.

Show that the solution is equivalent to the nearest shrunken centroid es-
timator (18.5), with s0 set to zero, and Mk equal to 1/Nk instead of
1/Nk −
Ex. 18.3 Show that the ﬁtted coeﬃcients for the regularized multiclass
ˆβkj = 0, j = 1, . . . , p.
logistic regression problem (18.10) satisfy
What about the ˆβk0? Discuss issues with these constant parameters, and
how they can be resolved.

K
k=1

P



Ex. 18.4 Derive the computational formula (18.15) for ridge regression.
[Hint: Use the ﬁrst derivative of the penalized sum-of-squares criterion to
show that if λ > 0, then ˆβ = XT s for some s

IRN .]

∈

Ex. 18.5 Prove the theorem (18.16)–(18.17) in Section 18.3.5, by decom-
posing β and the rows of X into their projections into the column space of
V and its complement in IRp.

Ex. 18.6 Show how the theorem in Section 18.3.5 can be applied to regu-
larized discriminant analysis [Section 4.14 and Equation (18.9)].

Exercises

695

Ex. 18.7 Consider a linear regression problem where p
N , and assume
the rank of X is N . Let the SVD of X = UDVT = RVT , where R is
N

N with orthonormal columns.

N nonsingular, and V is p

×
(a) Show that there are inﬁnitely many least-squares solutions all with

≫

×

zero residuals.

(b) Show that the ridge-regression estimate for β can be written

ˆβλ = V(RT R + λI)−1RT y

(18.56)

(c) Show that when λ = 0, the solution ˆβ0 = VD−1UT y has residuals
all equal to zero, and is unique in that it has the smallest Euclidean
norm amongst all zero-residual solutions.

Ex. 18.8 Data Piling. Exercise 4.2 shows that the two-class LDA solution
can be obtained by a linear regression of a binary response vector y con-
1s and +1s. The prediction ˆβT x for any x is (up to a scale and
sisting of
shift) the LDA score δ(x). Suppose now that p

N .

−

≫

(a) Consider the linear regression model f (x) = α + βT x ﬁt to a binary
response Y
. Using Exercise 18.7, show that there are
1, +1
}
inﬁnitely many directions deﬁned by ˆβ in IRp onto which the data
project to exactly two points, one for each class. These are known as
data piling directions (Ahn and Marron, 2005).

∈ {−

(b) Show that the distance between the projected points is 2/

, and
hence these directions deﬁne separating hyperplanes with that mar-
gin.

||

ˆβ
||

(c) Argue that there is a single maximal data piling direction for which
this distance is largest, and is deﬁned by ˆβ0 = VD−1UT y = X−y,
where X = UDVT is the SVD of X.

Ex. 18.9 Compare the data piling direction of Exercise 18.8 to the direction
of the optimal separating hyperplane (Section 4.5.2) qualitatively. Which
makes the widest margin, and why? Use a small simulation to demonstrate
the diﬀerence.

≫

Ex. 18.10 When p
N , linear discriminant analysis (see Section 4.3) is
degenerate because the within-class covariance matrix W is singular. One
version of regularized discriminant analysis (4.14) replaces W by a ridged
version W + λI, leading to a regularized discriminant function δλ(x) =
xT (W + λI)−1(¯x1 −
¯x−1). Show that δ0(x) = limλ↓0 δλ(x) corresponds to
the maximal data piling direction deﬁned in Exercise 18.8.

Ex. 18.11 Suppose you have a sample of N pairs (xi, yi), with yi binary
IR1. Suppose also that the two classes are separable; e.g., for each
and xi ∈

696

18. High-Dimensional Problems: p

N

≫

pair i, i′ with yi = 0 and yi′ = 1, xi′
to ﬁt a linear logistic regression model logitPr(Y = 1
|
maximum-likelihood. Show that ˆβ is undeﬁned.

xi ≥

−

C for some C > 0. You wish
X) = α + βX by

Ex. 18.12 Suppose we wish to select the ridge parameter λ by 10-fold cross-
N situation (for any linear model). We wish to use the
validation in a p
computational shortcuts described in Section 18.3.5. Show that we need
N matrix R once, and can
only to reduce the N
use it in all the cross-validation runs.

p matrix X to the N

≫

×

×

N inner-
Ex. 18.13 Suppose our p > N predictors are presented as an N
product matrix K = XXT , and we wish to ﬁt the equivalent of a linear
logistic regression model in the original features with quadratic regulariza-
tion. Our predictions are also to be made using inner products; a new x0
is presented as k0 = Xx0. Let K = UD2UT be the eigen-decomposition of
K. Show that the predictions are given by ˆf0 = kT

0 ˆα, where

×

(a) ˆα = UD−1 ˆβ, and

(b) ˆβ is the ridged logistic regression estimate with input matrix R =

UD.

Argue that the same approach can be used for any appropriate kernel
matrix K.

Ex. 18.14 Distance weighted 1-NN classiﬁcation. Consider the 1-nearest-
neighbor method (Section 13.3) in a two-class classiﬁcation problem. Let
d+(x0) be the shortest distance to a training observation in class +1, and
1. Let N− be the number
likewise d−(x0) the shortest distance for class
of samples in class

−
1, N+ the number in class +1, and N = N− + N+.

−

(a) Show that

δ(x0) = log

d−(x0)
d+(x0)

(18.57)

can be viewed as a nonparametric discriminant function correspond-
ing to 1-NN classiﬁcation. [Hint: Show that ˆf+(x0) =
N+d+(x0) can
be viewed as a nonparametric estimate of the density in class +1 at
x0].

1

(b) How would you modify this function to introduce class prior probabil-
ities π+ and π− diﬀerent from the sample-priors N+/N and N−/N ?

(c) How would you generalize this approach for K-NN classiﬁcation?

Ex. 18.15 Kernel PCA. In Section 18.5.2 we show how to compute the
principal component variables Z from an uncentered inner-product matrix
M) = UD2UT ,
K. We compute the eigen-decomposition (I
with M = 11T /N , and then Z = UD. Suppose we have the inner-product

M)K(I

−

−

Exercises

697

vector k0, containing the N inner-products between a new point x0 and
each of the xi in our training set. Show that the (centered) projections of
x0 onto the principal-component directions are given by

z0 = D−1UT (I

M) [k0 −

−

K1/N ] .

(18.58)

Ex. 18.16 Bonferroni method for multiple comparisons. Suppose we are in
a multiple-testing scenario with null hypotheses H0j, j = 1, 2, . . . , M , and
corresponding p-values pj, i = 1, 2, . . . , M . Let A be the event that at least
one null hypothesis is falsely rejected, and let Aj be the event that the
jth null hypothesis is falsely rejected. Suppose that we use the Bonferroni
method, rejecting the jth null hypothesis if pj < α/M .

(a) Show that Pr(A)

Pr(Aj ∩

Aj′ )]

α. [Hint: Pr(Aj ∪

≤

Aj′ ) = Pr(Aj) + Pr(Aj′ )

−

(b) If the hypotheses H0j, j = 1, 2, . . . , M , are independent, then Pr(A) =
α/M )M . Use this to show
j ) = 1

Pr(AC) = 1

M
j=1 Pr(AC

(1

−

−

1
that Pr(A)

−

−

α in this case.

≈

Q

Ex. 18.17 Equivalence between Benjamini–Hochberg and plug-in methods.

(a) In the notation of Algorithm 18.2, show that for rejection threshold
p0 = p(L), a proportion of at most p0 of the permuted values tk
j
exceed
.
tj|
Hence show that the plug-in FDR estimate [FDR is less than or equal
to p0 ·

|(L) is the Lth largest value among the

|(L) where

M/L = α.

T

T

|

|

|

(b) Show that the cut-point

greater than α.

T

|

|(L+1) produces a test with estimated FDR

Ex. 18.18 Use result (18.53) to show that

pFDR =

(Storey, 2003).

π0 · {

Type I error of Γ
+ π1{

}

}

Type I error of Γ

π0 · {

Power of Γ

(18.59)

}

Ex. 18.19 Consider the data in Table 18.4 of Section (18.7), available from
the book website.

(a) Using a symmetric two-sided rejection region based on the t-statistic,
compute the plug-in estimate of the FDR for various values of the
cut-point.

(b) Carry out the BH procedure for various FDR levels α and show the

equivalence of your results, with those from part (a).

698

18. High-Dimensional Problems: p

N

≫

(c) Let (q.25, q.75) be the quartiles of the t-statistics from the permuted
/(.5M ), and set ˆπ0 = min(ˆπ0, 1).
(q.25, q.75)
datasets. Let ˆπ0 =
}
Multiply the FDR estimates from (a) by ˆπ0 and examine the results.

#tj ∈
{

(d) Give a motivation for the estimate in part (c).

(Storey, 2003)

Ex. 18.20 Proof of result (18.53). Write

pFDR = E

V
R |

R > 0

!

=

M

Xk=1

V
R |

E

"

R = k

Pr(R = k

R > 0)

|

#

(18.60)

(18.61)

Use the fact that given R = k, V is a binomial random variable, with k
Γ), to complete the proof.
trials and probability of success Pr(H = 0
|

∈

T

 
References

This is page 699
Printer: Opaque this

Abu-Mostafa, Y. (1995). Hints, Neural Computation 7: 639–671.

Ackley, D. H., Hinton, G. and Sejnowski, T. (1985). A learning algorithm
for Boltzmann machines, Trends in Cognitive Sciences 9: 147–169.

Adam, B.-L., Qu, Y., Davis, J. W., Ward, M. D., Clements, M. A.,
Cazares, L. H., Semmes, O. J., Schellhammer, P. F., Yasui, Y.,
Feng, Z. and Wright, G. (2003). Serum protein ﬁngerprinting cou-
pled with a pattern-matching algorithm distinguishes prostate cancer
from benign prostate hyperplasia and healthy mean, Cancer Research
63(10): 3609–3614.

Agrawal, R., Mannila, H., Srikant, R., Toivonen, H. and Verkamo, A. I.
(1995). Fast discovery of association rules, Advances in Knowledge
Discovery and Data Mining, AAAI/MIT Press, Cambridge, MA.

Agresti, A. (1996). An Introduction to Categorical Data Analysis, Wiley,

New York.

Agresti, A. (2002). Categorical Data Analysis (2nd Ed.), Wiley, New York.

Ahn, J. and Marron, J. (2005). The direction of maximal data piling in high
dimensional space, Technical report, Statistics Department, University
of North Carolina, Chapel Hill.

Akaike, H. (1973). Information theory and an extension of the maximum
likelihood principle, Second International Symposium on Information
Theory, pp. 267–281.

700

References

Allen, D. (1974). The relationship between variable selection and data
augmentation and a method of prediction, Technometrics 16: 125–7.

Ambroise, C. and McLachlan, G. (2002). Selection bias in gene extraction
on the basis of microarray gene-expression data, Proceedings of the
National Academy of Sciences 99: 6562–6566.

Amit, Y. and Geman, D. (1997). Shape quantization and recognition with

randomized trees, Neural Computation 9: 1545–1588.

Anderson, J. and Rosenfeld, E. (eds) (1988). Neurocomputing: Foundations

of Research, MIT Press, Cambridge, MA.

Anderson, T. (2003). An Introduction to Multivariate Statistical Analysis,

3rd ed., Wiley, New York.

Bach, F. and Jordan, M. (2002). Kernel independent component analysis,

Journal of Machine Learning Research 3: 1–48.

Bair, E. and Tibshirani, R. (2004). Semi-supervised methods to predict
patient survival from gene expression data, PLOS Biology 2: 511–522.

Bair, E., Hastie, T., Paul, D. and Tibshirani, R. (2006). Prediction by
supervised principal components, Journal of the American Statistical
Association 101: 119–137.

Bakin, S. (1999). Adaptive regression and model selection in data mining
problems, Technical report, PhD. thesis, Australian National Univer-
sity, Canberra.

Banerjee, O., Ghaoui, L. E. and d’Aspremont, A. (2008). Model selection
through sparse maximum likelihood estimation for multivariate gaus-
sian or binary data, Journal of Machine Learning Research 9: 485–516.

Barron, A. (1993). Universal approximation bounds for superpositions of a
sigmoid function, IEEE Transactions on Information Theory 39: 930–
945.

Bartlett, P. and Traskin, M.

in
B. Sch¨olkopf, J. Platt and T. Hoﬀman (eds), Advances in Neural Infor-
mation Processing Systems 19, MIT Press, Cambridge, MA, pp. 105–
112.

is consistent,

Adaboost

(2007).

Becker, R., Cleveland, W. and Shyu, M. (1996). The visual design and con-
trol of trellis display, Journal of Computational and Graphical Statis-
tics 5: 123–155.

Bell, A. and Sejnowski, T. (1995). An information-maximization approach
to blind separation and blind deconvolution, Neural Computation
7: 1129–1159.

References

701

Bellman, R. E. (1961). Adaptive Control Processes, Princeton University

Press.

Benjamini, Y. and Hochberg, Y. (1995). Controlling the false discovery
rate: a practical and powerful approach to multiple testing, Journal of
the Royal Statistical Society Series B. 85: 289–300.

Benjamini, Y. and Yekutieli, Y. (2005). False discovery rate controlling
conﬁdence intervals for selected parameters, Journal of the American
Statistical Association 100: 71–80.

Bickel, P. and Levina, E. (2004). Some theory for Fisher’s linear discrim-
inant function,“Naive Bayes”, and some alternatives when there are
many more variables than observations, Bernoulli 10: 989–1010.

Bickel, P. J., Ritov, Y. and Tsybakov, A. (2008). Simultaneous analysis of

lasso and Dantzig selector, Annals of Statistics. to appear.

Bishop, C. (1995). Neural Networks for Pattern Recognition, Clarendon

Press, Oxford.

Bishop, C. (2006). Pattern Recognition and Machine Learning, Springer,

New York.

Bishop, Y., Fienberg, S. and Holland, P. (1975). Discrete Multivariate

Analysis, MIT Press, Cambridge, MA.

Boyd, S. and Vandenberghe, L. (2004). Convex Optimization, Cambridge

University Press.

Breiman, L. (1992). The little bootstrap and other methods for dimension-
ality selection in regression: X-ﬁxed prediction error, Journal of the
American Statistical Association 87: 738–754.

Breiman, L. (1996a). Bagging predictors, Machine Learning 26: 123–140.

Breiman, L. (1996b). Stacked regressions, Machine Learning 24: 51–64.

Breiman, L. (1998). Arcing classiﬁers (with discussion), Annals of Statistics

26: 801–849.

Breiman, L. (1999). Prediction games and arcing algorithms, Neural Com-

putation 11(7): 1493–1517.

Breiman, L. (2001). Random forests, Machine Learning 45: 5–32.

Breiman, L. and Friedman, J. (1997). Predicting multivariate responses
in multiple linear regression (with discussion), Journal of the Royal
Statistical Society Series B. 59: 3–37.

702

References

Breiman, L. and Ihaka, R. (1984). Nonlinear discriminant analysis via
scaling and ACE, Technical report, University of California, Berkeley.

Breiman, L. and Spector, P. (1992). Submodel selection and evaluation
in regression: the X-random case, International Statistical Review
60: 291–319.

Breiman, L., Friedman, J., Olshen, R. and Stone, C. (1984). Classiﬁcation

and Regression Trees, Wadsworth, New York.

Bremaud, P. (1999). Markov Chains: Gibbs Fields, Monte Carlo Simula-

tion, and Queues, Springer, New York.

Brown, P., Spiegelman, C. and Denham, M. (1991). Chemometrics and
spectral frequency selection, Transactions of the Royal Society of Lon-
don Series A. 337: 311–322.

Bruce, A. and Gao, H. (1996). Applied Wavelet Analysis with S-PLUS,

Springer, New York.

B¨uhlmann, P. and Hothorn, T. (2007). Boosting algorithms: regulariza-
tion, prediction and model ﬁtting (with discussion), Statistical Science
22(4): 477–505.

Buja, A., Hastie, T. and Tibshirani, R. (1989). Linear smoothers and

additive models (with discussion), Annals of Statistics 17: 453–555.

Buja, A., Swayne, D., Littman, M., Hofmann, H. and Chen, L. (2008). Data
vizualization with multidimensional scaling, Journal of Computational
and Graphical Statistics. to appear.

Bunea, F., Tsybakov, A. and Wegkamp, M. (2007). Sparsity oracle inequal-

ities for the lasso, Electronic Journal of Statistics 1: 169–194.

Burges, C. (1998). A tutorial on support vector machines for pattern recog-

nition, Knowledge Discovery and Data Mining 2(2): 121–167.

Butte, A., Tamayo, P., Slonim, D., Golub, T. and Kohane, I. (2000).
Discovering functional relationships between RNA expression and
chemotherapeutic susceptibility using relevance networks, Proceedings
of the National Academy of Sciences pp. 12182–12186.

Candes, E. (2006). Compressive sampling, Proceedings of the Interna-
tional Congress of Mathematicians, European Mathematical Society,
Madrid, Spain.

Candes, E. and Tao, T. (2007). The Dantzig selector: Statistical estimation
when p is much larger than n, Annals of Statistics 35(6): 2313–2351.

References

703

Chambers, J. and Hastie, T.

(1991).

Statistical Models

in S,

Wadsworth/Brooks Cole, Paciﬁc Grove, CA.

Chaudhuri, S., Drton, M. and Richardson, T. S. (2007). Estimation of a

covariance matrix with zeros, Biometrika 94(1): 1–18.

Chen, L. and Buja, A. (2008). Local multidimensional scaling for nonlinear
dimension reduction, graph drawing and proximity analysis, Journal
of the American Statistical Association.

Chen, S. S., Donoho, D. and Saunders, M. (1998). Atomic decomposition
by basis pursuit, SIAM Journal on Scientiﬁc Computing 20(1): 33–61.

Cherkassky, V. and Ma, Y. (2003). Comparison of model selection for

regression, Neural computation 15(7): 1691–1714.

Cherkassky, V. and Mulier, F. (2007). Learning from Data (2nd Edition),

Wiley, New York.

Chui, C. (1992). An Introduction to Wavelets, Academic Press, London.

Cliﬀord, P. (1990). Markov random ﬁelds in statistics, in G. R. Grimmett
and D. J. A. Welsh (eds), Disorder in Physical Systems. A Volume in
Honour of John M. Hammersley, Clarendon Press, Oxford, pp. 19–32.

Comon, P. (1994). Independent component analysis—a new concept?, Sig-

nal Processing 36: 287–314.

Cook, D. and Swayne, D. (2007). Interactive and Dynamic Graphics for
Data Analysis; with R and GGobi, Springer, New York. With con-
tributions from A. Buja, D. Temple Lang, H. Hofmann, H. Wickham
and M. Lawrence.

Cook, N. (2007). Use and misuse of the receiver operating characteristic

curve in risk prediction, Circulation 116(6): 928–35.

Copas, J. B. (1983). Regression, prediction and shrinkage (with discus-
sion), Journal of the Royal Statistical Society, Series B, Methodological
45: 311–354.

Cover, T. and Hart, P. (1967). Nearest neighbor pattern classiﬁcation,

IEEE Transactions on Information Theory IT-11: 21–27.

Cover, T. and Thomas, J. (1991). Elements of Information Theory, Wiley,

New York.

Cox, D. and Hinkley, D. (1974). Theoretical Statistics, Chapman and Hall,

London.

704

References

Cox, D. and Wermuth, N. (1996). Multivariate Dependencies: Models,

Analysis and Interpretation, Chapman and Hall, London.

Cressie, N. (1993). Statistics for Spatial Data (Revised Edition), Wiley-

Interscience, New York.

Csiszar, I. and Tusn´ady, G. (1984). Information geometry and alternat-
ing minimization procedures, Statistics & Decisions Supplement Issue
1: 205–237.

Cutler, A. and Breiman, L. (1994). Archetypal analysis, Technometrics

36(4): 338–347.

Dasarathy, B. (1991). Nearest Neighbor Pattern Classiﬁcation Techniques,

IEEE Computer Society Press, Los Alamitos, CA.

Daubechies, I. (1992). Ten Lectures on Wavelets, Society for Industrial and

Applied Mathematics, Philadelphia, PA.

Daubechies, I., Defrise, M. and De Mol, C. (2004). An iterative threshold-
ing algorithm for linear inverse problems with a sparsity constraint,
Communications on Pure and Applied Mathematics 57: 1413–1457.

de Boor, C. (1978). A Practical Guide to Splines, Springer, New York.

Dempster, A. (1972). Covariance selection, Biometrics 28: 157–175.

Dempster, A., Laird, N. and Rubin, D. (1977). Maximum likelihood from
incomplete data via the EM algorithm (with discussion), Journal of
the Royal Statistical Society Series B 39: 1–38.

Devijver, P. and Kittler, J. (1982). Pattern Recognition: A Statistical Ap-

proach, Prentice-Hall, Englewood Cliﬀs, N.J.

Dietterich, T. (2000a). Ensemble methods in machine learning, Lecture

Notes in Computer Science 1857: 1–15.

Dietterich, T. (2000b). An experimental comparison of three methods for
constructing ensembles of decision trees: bagging, boosting, and ran-
domization, Machine Learning 40(2): 139–157.

Dietterich, T. and Bakiri, G. (1995). Solving multiclass learning problems
via error-correcting output codes, Journal of Artiﬁcial Intelligence Re-
search 2: 263–286.

Donath, W. E. and Hoﬀman, A. J. (1973). Lower bounds for the partition-
ing of graphs, IBM Journal of Research and Development pp. 420–425.

Donoho, D. (2006a). Compressed sensing, IEEE Transactions on Informa-

tion Theory 52(4): 1289–1306.

References

705

Donoho, D. (2006b). For most large underdetermined systems of equations,
the minimal ℓ1-norm solution is the sparsest solution, Communications
on Pure and Applied Mathematics 59: 797–829.

Donoho, D. and Elad, M. (2003). Optimally sparse representation from
overcomplete dictionaries via ℓ1-norm minimization, Proceedings of
the National Academy of Sciences 100: 2197–2202.

Donoho, D. and Johnstone, I. (1994). Ideal spatial adaptation by wavelet

shrinkage, Biometrika 81: 425–455.

Donoho, D. and Stodden, V. (2004). When does non-negative matrix
factorization give a correct decomposition into parts?, in S. Thrun,
L. Saul and B. Sch¨olkopf (eds), Advances in Neural Information Pro-
cessing Systems 16, MIT Press, Cambridge, MA.

Duan, N. and Li, K.-C. (1991). Slicing regression: a link-free regression

method, Annals of Statistics 19: 505–530.

Duchamp, T. and Stuetzle, W. (1996). Extremal properties of principal

curves in the plane, Annals of Statistics 24: 1511–1520.

Duda, R., Hart, P. and Stork, D. (2000). Pattern Classiﬁcation (2nd Edi-

tion), Wiley, New York.

Dudoit, S., Fridlyand, J. and Speed, T. (2002a). Comparison of discrimi-
nation methods for the classiﬁcation of tumors using gene expression
data, Journal of the American Statistical Association 97(457): 77–87.

Dudoit, S., Yang, Y., Callow, M. and Speed, T. (2002b). Statistical meth-
ods for identifying diﬀerentially expressed genes in replicated cDNA
microarray experiments, Statistica Sinica pp. 111–139.

Edwards, D. (2000).

Introduction to Graphical Modelling, 2nd Edition,

Springer, New York.

Efron, B. (1975). The eﬃciency of logistic regression compared to normal
discriminant analysis, Journal of the American Statistical Association
70: 892–898.

Efron, B. (1979). Bootstrap methods: another look at the jackknife, Annals

of Statistics 7: 1–26.

Efron, B. (1983). Estimating the error rate of a prediction rule: some
improvements on cross-validation, Journal of the American Statistical
Association 78: 316–331.

Efron, B. (1986). How biased is the apparent error rate of a prediction
rule?, Journal of the American Statistical Association 81: 461–70.

706

References

Efron, B. and Tibshirani, R. (1991). Statistical analysis in the computer

age, Science 253: 390–395.

Efron, B. and Tibshirani, R. (1993). An Introduction to the Bootstrap,

Chapman and Hall, London.

Efron, B. and Tibshirani, R. (1996). Using specially designed exponential
families for density estimation, Annals of Statistics 24(6): 2431–2461.

Efron, B. and Tibshirani, R. (1997). Improvements on cross-validation: the
632+ bootstrap: method, Journal of the American Statistical Associ-
ation 92: 548–560.

Efron, B. and Tibshirani, R. (2002). Microarrays, empirical Bayes methods,

and false discovery rates, Genetic Epidemiology 1: 70–86.

Efron, B., Hastie, T. and Tibshirani, R. (2007). Discussion of “Dantzig
selector” by Candes and Tao, Annals of Statistics 35(6): 2358–2364.

Efron, B., Hastie, T., Johnstone, I. and Tibshirani, R. (2004). Least angle
regression (with discussion), Annals of Statistics 32(2): 407–499.

Efron, B., Tibshirani, R., Storey, J. and Tusher, V. (2001). Empirical
Bayes analysis of a microarray experiment, Journal of the American
Statistical Association 96: 1151–1160.

Evgeniou, T., Pontil, M. and Poggio, T. (2000). Regularization networks
and support vector machines, Advances in Computational Mathemat-
ics 13(1): 1–50.

Fan, J. and Fan, Y. (2008). High dimensional classiﬁcation using features

annealed independence rules, Annals of Statistics. to appear.

Fan, J. and Gijbels, I. (1996). Local Polynomial Modelling and Its Appli-

cations, Chapman and Hall, London.

Fan, J. and Li, R. (2005). Variable selection via nonconcave penalized
likelihood and its oracle properties, Journal of the American Statistical
Association 96: 1348–1360.

Fiedler, M. (1973). Algebraic connectivity of graphs, Czechoslovak Mathe-

matics Journal 23(98): 298–305.

Fienberg, S. (1977). The Analysis of Cross-Classiﬁed Categorical Data,

MIT Press, Cambridge.

Fisher, R. A. (1936). The use of multiple measurements in taxonomic

problems, Eugen. 7: 179–188.

References

707

Fisher, W. (1958). On grouping for maximum homogeniety, Journal of the

American Statistical Association 53(284): 789–798.

Fix, E. and Hodges, J. (1951). Discriminatory analysis—nonparametric
discrimination: Consistency properties, Technical Report 21-49-004,4,
U.S. Air Force, School of Aviation Medicine, Randolph Field, TX.

Flury, B. (1990). Principal points, Biometrika 77: 33–41.

Forgy, E. (1965). Cluster analysis of multivariate data: eﬃciency vs. inter-

pretability of classiﬁcations, Biometrics 21: 768–769.

Frank, I. and Friedman, J. (1993). A statistical view of some chemometrics
regression tools (with discussion), Technometrics 35(2): 109–148.

Freund, Y. (1995). Boosting a weak learning algorithm by majority, Infor-

mation and Computation 121(2): 256–285.

Freund, Y. and Schapire, R. (1996a). Experiments with a new boosting
algorithm, Machine Learning: Proceedings of the Thirteenth Interna-
tional Conference, Morgan Kauﬀman, San Francisco, pp. 148–156.

Freund, Y. and Schapire, R. (1996b). Game theory, on-line prediction and
boosting, Proceedings of the Ninth Annual Conference on Computa-
tional Learning Theory, Desenzano del Garda, Italy, pp. 325–332.

Freund, Y. and Schapire, R. (1997). A decision-theoretic generalization of
online learning and an application to boosting, Journal of Computer
and System Sciences 55: 119–139.

Friedman, J. (1987). Exploratory projection pursuit, Journal of the Amer-

ican Statistical Association 82: 249–266.

Friedman, J. (1989). Regularized discriminant analysis, Journal of the

American Statistical Association 84: 165–175.

Friedman, J. (1991). Multivariate adaptive regression splines (with discus-

sion), Annals of Statistics 19(1): 1–141.

Friedman, J. (1994a). Flexible metric nearest-neighbor classiﬁcation, Tech-

nical report, Stanford University.

Friedman, J. (1994b). An overview of predictive learning and function
approximation, in V. Cherkassky, J. Friedman and H. Wechsler (eds),
From Statistics to Neural Networks, Vol. 136 of NATO ISI Series F,
Springer, New York.

Friedman, J. (1996). Another approach to polychotomous classiﬁcation,

Technical report, Stanford University.

708

References

Friedman, J. (1997). On bias, variance, 0-1 loss and the curse of dimen-
sionality, Journal of Data Mining and Knowledge Discovery 1: 55–77.

Friedman, J. (1999). Stochastic gradient boosting, Technical report, Stan-

ford University.

Friedman, J. (2001). Greedy function approximation: A gradient boosting

machine, Annals of Statistics 29(5): 1189–1232.

Friedman, J. and Fisher, N. (1999). Bump hunting in high dimensional

data, Statistics and Computing 9: 123–143.

Friedman, J. and Hall, P. (2007). On bagging and nonlinear estimation,

Journal of Statistical Planning and Inference 137: 669–683.

Friedman, J. and Popescu, B. (2003). Importance sampled learning ensem-
bles, Technical report, Stanford University, Department of Statistics.

Friedman, J. and Popescu, B. (2008). Predictive learning via rule ensem-

bles, Annals of Applied Statistics, to appear.

Friedman, J. and Silverman, B. (1989). Flexible parsimonious smoothing
and additive modelling (with discussion), Technometrics 31: 3–39.

Friedman, J. and Stuetzle, W. (1981). Projection pursuit regression, Jour-

nal of the American Statistical Association 76: 817–823.

Friedman, J. and Tukey, J. (1974). A projection pursuit algorithm for
exploratory data analysis, IEEE Transactions on Computers, Series
C 23: 881–889.

Friedman, J., Baskett, F. and Shustek, L. (1975). An algorithm for ﬁnding
nearest neighbors, IEEE Transactions on Computers 24: 1000–1006.

Friedman, J., Bentley, J. and Finkel, R. (1977). An algorthm for ﬁnd-
ing best matches in logarithmic expected time, ACM Transactions on
Mathematical Software 3: 209–226.

Friedman, J., Hastie, T. and Tibshirani, R. (2000). Additive logistic re-
gression: a statistical view of boosting (with discussion), Annals of
Statistics 28: 337–307.

Friedman, J., Hastie, T. and Tibshirani, R. (2008a). Response to “Mease
and Wyner: Evidence contrary to the statistical view of boosting”,
Journal of Machine Learning Research 9: 175–180.

Friedman, J., Hastie, T. and Tibshirani, R. (2008b). Sparse inverse covari-
ance estimation with the graphical lasso, Biostatistics 9: 432–441.

References

709

Friedman, J., Hastie, T. and Tibshirani, R. (2010). Regularization paths for
generalized linear models via coordinate descent, Journal of Statistical
Software 33(1): 1–22.

Friedman, J., Hastie, T., Hoeﬂing, H. and Tibshirani, R. (2007). Pathwise

coordinate optimization, Annals of Applied Statistics 2(1): 302–332.

Friedman, J., Hastie, T., Rosset, S., Tibshirani, R. and Zhu, J. (2004).
Discussion of three boosting papers by Jiang, Lugosi and Vayatis, and
Zhang, Annals of Statistics 32: 102–107.

Friedman, J., Stuetzle, W. and Schroeder, A. (1984). Projection pursuit
density estimation, Journal of the American Statistical Association
79: 599–608.

Fu, W. (1998). Penalized regressions: the bridge vs. the lasso, Journal of

Computational and Graphical Statistics 7(3): 397–416.

Furnival, G. and Wilson, R. (1974). Regression by leaps and bounds, Tech-

nometrics 16: 499–511.

Gelfand, A. and Smith, A. (1990). Sampling based approaches to calculat-
ing marginal densities, Journal of the American Statistical Association
85: 398–409.

Gelman, A., Carlin, J., Stern, H. and Rubin, D. (1995). Bayesian Data

Analysis, CRC Press, Boca Raton, FL.

Geman, S. and Geman, D. (1984). Stochastic relaxation, Gibbs distribu-
tions and the Bayesian restoration of images, IEEE Transactions on
Pattern Analysis and Machine Intelligence 6: 721–741.

Genkin, A., Lewis, D. and Madigan, D. (2007). Large-scale Bayesian logis-
tic regression for text categorization, Technometrics 49(3): 291–304.

Genovese, C. and Wasserman, L. (2004). A stochastic process approach to

false discovery rates, Annals of Statistics 32(3): 1035–1061.

Gersho, A. and Gray, R. (1992). Vector Quantization and Signal Compres-

sion, Kluwer Academic Publishers, Boston, MA.

Girosi, F., Jones, M. and Poggio, T. (1995). Regularization theory and
neural network architectures, Neural Computation 7: 219–269.

Golub, G. and Van Loan, C. (1983). Matrix Computations, Johns Hopkins

University Press, Baltimore.

Golub, G., Heath, M. and Wahba, G. (1979). Generalized cross-validation
as a method for choosing a good ridge parameter, Technometrics
21: 215–224.

710

References

Golub, T., Slonim, D., Tamayo, P., Huard, C., Gaasenbeek, M., Mesirov,
J., Coller, H., Loh, M., Downing, J., Caligiuri, M., Bloomﬁeld, C. and
Lander, E. (1999). Molecular classiﬁcation of cancer: Class discovery
and class prediction by gene expression monitoring, Science 286: 531–
536.

Goodall, C. (1991). Procrustes methods in the statistical analysis of shape,
Journal of the Royal Statistical Society, Series B 53: 285–321.

Gordon, A. (1999). Classiﬁcation (2nd edition), Chapman and Hall/CRC

Press, London.

Green, P. and Silverman, B. (1994). Nonparametric Regression and Gener-
alized Linear Models: A Roughness Penalty Approach, Chapman and
Hall, London.

Greenacre, M. (1984). Theory and Applications of Correspondence Analy-

sis, Academic Press, New York.

Greenshtein, E. and Ritov, Y. (2004). Persistence in high-dimensional lin-
ear predictor selection and the virtue of overparametrization, Bernoulli
10: 971–988.

Guo, Y., Hastie, T. and Tibshirani, R. (2006). Regularized linear discrim-
inant analysis and its application in microarrays, Biostatistics 8: 86–
100.

Guyon, I., Gunn, S., Nikravesh, M. and Zadeh, L. (eds) (2006). Feature
Extraction, Foundations and Applications, Springer, New York.

Guyon, I., Weston, J., Barnhill, S. and Vapnik, V. (2002). Gene selection for
cancer classiﬁcation using support vector machines, Machine Learning
46: 389–422.

Hall, P. (1992). The Bootstrap and Edgeworth Expansion, Springer, New

York.

Hammersley, J. M. and Cliﬀord, P. (1971). Markov ﬁeld on ﬁnite graphs

and lattices, unpublished.

Hand, D. (1981). Discrimination and Classiﬁcation, Wiley, Chichester.

Hanley, J. and McNeil, B. (1982). The meaning and use of the area under
a receiver operating characteristic (roc) curve, Radiology 143: 29–36.

Hart, P. (1968). The condensed nearest-neighbor rule, IEEE Transactions

on Information Theory 14: 515–516.

Hartigan, J. A. (1975). Clustering Algorithms, Wiley, New York.

References

711

Hartigan, J. A. and Wong, M. A. (1979). [(Algorithm AS 136] A k-means
clustering algorithm (AS R39: 81v30 p355-356), Applied Statistics
28: 100–108.

Hastie, T. (1984). Principal Curves and Surfaces, PhD thesis, Stanford

University.

Hastie, T. and Herman, A. (1990). An analysis of gestational age, neona-
tal size and neonatal death using nonparametric logistic regression,
Journal of Clinical Epidemiology 43: 1179–90.

Hastie, T. and Simard, P. (1998). Models and metrics for handwritten digit

recognition, Statistical Science 13: 54–65.

Hastie, T. and Stuetzle, W. (1989). Principal curves, Journal of the Amer-

ican Statistical Association 84(406): 502–516.

Hastie, T. and Tibshirani, R. (1987). Nonparametric logistic and propor-

tional odds regression, Applied Statistics 36: 260–276.

Hastie, T. and Tibshirani, R. (1990). Generalized Additive Models, Chap-

man and Hall, London.

Hastie, T. and Tibshirani, R. (1996a). Discriminant adaptive nearest-
neighbor classiﬁcation, IEEE Pattern Recognition and Machine In-
telligence 18: 607–616.

Hastie, T. and Tibshirani, R. (1996b). Discriminant analysis by Gaussian
mixtures, Journal of the Royal Statistical Society Series B. 58: 155–
176.

Hastie, T. and Tibshirani, R. (1998). Classiﬁcation by pairwise coupling,

Annals of Statistics 26(2): 451–471.

Hastie, T. and Tibshirani, R. (2003).

Independent components analysis
through product density estimation, in S. T. S. Becker and K. Ober-
mayer (eds), Advances in Neural Information Processing Systems 15,
MIT Press, Cambridge, MA, pp. 649–656.

Hastie, T. and Tibshirani, R. (2004). Eﬃcient quadratic regularization for

expression arrays, Biostatistics 5(3): 329–340.

Hastie, T. and Zhu, J. (2006). Discussion of “Support vector machines
with applications” by Javier Moguerza and Alberto Munoz, Statistical
Science 21(3): 352–357.

Hastie, T., Botha, J. and Schnitzler, C. (1989). Regression with an ordered

categorical response, Statistics in Medicine 43: 884–889.

712

References

Hastie, T., Buja, A. and Tibshirani, R. (1995). Penalized discriminant

analysis, Annals of Statistics 23: 73–102.

Hastie, T., Kishon, E., Clark, M. and Fan, J. (1992). A model for
signature veriﬁcation, Technical report, AT&T Bell Laboratories.
http://www-stat.stanford.edu/

hastie/Papers/signature.pdf.

∼

Hastie, T., Rosset, S., Tibshirani, R. and Zhu, J. (2004). The entire reg-
ularization path for the support vector machine, Journal of Machine
Learning Research 5: 1391–1415.

Hastie, T., Taylor, J., Tibshirani, R. and Walther, G. (2007). Forward
stagewise regression and the monotone lasso, Electronic Journal of
Statistics 1: 1–29.

Hastie, T., Tibshirani, R. and Buja, A. (1994). Flexible discriminant analy-
sis by optimal scoring, Journal of the American Statistical Association
89: 1255–1270.

Hastie, T., Tibshirani, R. and Buja, A. (2000). Flexible discriminant and
mixture models, in J. Kay and M. Titterington (eds), Statistics and
Artiﬁcial Neural Networks, Oxford University Press.

Hastie, T., Tibshirani, R. and Friedman, J. (2003). A note on “Compari-
son of model selection for regression” by Cherkassky and Ma, Neural
computation 15(7): 1477–1480.

Hathaway, R. J. (1986). Another interpretation of the EM algorithm for
mixture distributions, Statistics & Probability Letters 4: 53–56.

Hebb, D. (1949). The Organization of Behavior, Wiley, New York.

Hertz, J., Krogh, A. and Palmer, R. (1991). Introduction to the Theory of

Neural Computation, Addison Wesley, Redwood City, CA.

Hinton, G. (1989). Connectionist learning procedures, Artiﬁcial Intelli-

gence 40: 185–234.

Hinton, G. (2002). Training products of experts by minimizing contrastive

divergence, Neural Computation 14: 1771–1800.

Hinton, G., Osindero, S. and Teh, Y.-W. (2006). A fast learning algorithm

for deep belief nets, Neural Computation 18: 1527–1554.

Ho, T. K. (1995). Random decision forests, in M. Kavavaugh and P. Storms
(eds), Proc. Third International Conference on Document Analysis
and Recognition, Vol. 1, IEEE Computer Society Press, New York,
pp. 278–282.

References

713

Hoeﬂing, H. and Tibshirani, R. (2008). Estimation of sparse Markov net-
works using modiﬁed logistic regression and the lasso, submitted.

Hoerl, A. E. and Kennard, R. (1970). Ridge regression: biased estimation

for nonorthogonal problems, Technometrics 12: 55–67.

Hothorn, T. and B¨uhlmann, P. (2006). Model-based boosting in high di-

mensions, Bioinformatics 22(22): 2828–2829.

Huber, P. (1964). Robust estimation of a location parameter, Annals of

Mathematical Statistics 53: 73–101.

Huber, P. (1985). Projection pursuit, Annals of Statistics 13: 435–475.

Hunter, D. and Lange, K. (2004). A tutorial on MM algorithms, The

American Statistician 58(1): 30–37.

Hyv¨arinen, A. and Oja, E. (2000). Independent component analysis: algo-

rithms and applications, Neural Networks 13: 411–430.

Hyv¨arinen, A., Karhunen, J. and Oja, E. (2001). Independent Component

Analysis, Wiley, New York.

Izenman, A. (1975). Reduced-rank regression for the multivariate linear

model, Journal of Multivariate Analysis 5: 248–264.

Jacobs, R., Jordan, M., Nowlan, S. and Hinton, G. (1991). Adaptive mix-

tures of local experts, Neural computation 3: 79–87.

Jain, A. and Dubes, R. (1988). Algorithms for Clustering Data, Prentice-

Hall, Englewood Cliﬀs, N.J.

James, G. and Hastie, T. (1998). The error coding method and PICTs,
Journal of Computational and Graphical Statistics 7(3): 377–387.

Jancey, R. (1966). Multidimensional group analysis, Australian Journal of

Botany 14: 127–130.

Jensen, F. V., Lauritzen, S. and Olesen, K. G. (1990). Bayesian updating
in recursive graphical models by local computation, Computational
Statistics Quarterly 4: 269–282.

Jiang, W. (2004). Process consistency for Adaboost, Annals of Statistics

32(1): 13–29.

Jirou´sek, R. and Pˇreuˇcil, S. (1995). On the eﬀective implementation of the
iterative proportional ﬁtting procedure, Computational Statistics and
Data Analysis 19: 177–189.

Johnson, N. (2008). A study of the NIPS feature selection challenge, Sub-

mitted.

714

References

Joliﬀe, I. T., Trendaﬁlov, N. T. and Uddin, M. (2003). A modiﬁed principal
component technique based on the lasso, Journal of Computational
and Graphical Statistics 12: 531–547.

Jones, L. (1992). A simple lemma on greedy approximation in Hilbert space
and convergence rates for projection pursuit regression and neural
network training, Annals of Statistics 20: 608–613.

Jordan, M. (2004). Graphical models, Statistical Science (Special Issue on

Bayesian Statistics) 19: 140–155.

Jordan, M. and Jacobs, R. (1994). Hierachical mixtures of experts and the

EM algorithm, Neural Computation 6: 181–214.

Kalbﬂeisch, J. and Prentice, R. (1980). The Statistical Analysis of Failure

Time Data, Wiley, New York.

Kaufman, L. and Rousseeuw, P. (1990). Finding Groups in Data: An In-

troduction to Cluster Analysis, Wiley, New York.

Kearns, M. and Vazirani, U. (1994). An Introduction to Computational

Learning Theory, MIT Press, Cambridge, MA.

Kittler, J., Hatef, M., Duin, R. and Matas, J. (1998). On combining classi-
ﬁers, IEEE Transaction on Pattern Analysis and Machine Intelligence
20(3): 226–239.

Kleinberg, E. M. (1990). Stochastic discrimination, Annals of Mathematical

Artiﬁcial Intelligence 1: 207–239.

Kleinberg, E. M. (1996). An overtraining-resistant stochastic modeling

method for pattern recognition, Annals of Statistics 24: 2319–2349.

Knight, K. and Fu, W. (2000). Asymptotics for lasso-type estimators,

Annals of Statistics 28(5): 1356–1378.

Koh, K., Kim, S.-J. and Boyd, S. (2007). An interior-point method
for large-scale L1-regularized logistic regression, Journal of Machine
Learning Research 8: 1519–1555.

Kohavi, R. (1995). A study of cross-validation and bootstrap for accu-
racy estimation and model selection, International Joint Conference
on Artiﬁcial Intelligence (IJCAI), Morgan Kaufmann, pp. 1137–1143.

Kohonen, T. (1989). Self-Organization and Associative Memory (3rd edi-

tion), Springer, Berlin.

Kohonen, T. (1990). The self-organizing map, Proceedings of the IEEE

78: 1464–1479.

References

715

Kohonen, T., Kaski, S., Lagus, K., Saloj¨arvi, J., Paatero, A. and Saarela,
A. (2000). Self-organization of a massive document collection, IEEE
Transactions on Neural Networks 11(3): 574–585. Special Issue on
Neural Networks for Data Mining and Knowledge Discovery.

Koller, D. and Friedman, N. (2007). Structured Probabilistic Models, Stan-

ford Bookstore Custom Publishing. (Unpublished Draft).

Kressel, U. (1999). Pairwise classiﬁcation and support vector machines,
in B. Sch¨olkopf, C. Burges and A. Smola (eds), Advances in Ker-
nel Methods - Support Vector Learning, MIT Press, Cambridge, MA.,
pp. 255–268.

Lambert, D. (1992). Zero-inﬂated Poisson regression, with an application

to defects in manufacturing, Technometrics 34(1): 1–14.

Lange, K. (2004). Optimization, Springer, New York.

Lauritzen, S. (1996). Graphical Models, Oxford University Press.

Lauritzen, S. and Spiegelhalter, D. (1988). Local computations with proba-
bilities on graphical structures and their application to expert systems,
J. Royal Statistical Society B. 50: 157–224.

Lawson, C. and Hansen, R. (1974).

Solving Least Squares Problems,

Prentice-Hall, Englewood Cliﬀs, NJ.

Le Cun, Y. (1989). Generalization and network design strategies, Techni-
cal Report CRG-TR-89-4, Department of Computer Science, Univ. of
Toronto.

Le Cun, Y., Boser, B., Denker, J., Henderson, D., Howard, R., Hubbard,
W. and Jackel, L. (1990). Handwritten digit recognition with a back-
propogation network, in D. Touretzky (ed.), Advances in Neural In-
formation Processing Systems, Vol. 2, Morgan Kaufman, Denver, CO,
pp. 386–404.

Le Cun, Y., Bottou, L., Bengio, Y. and Haﬀner, P. (1998). Gradient-based
learning applied to document recognition, Proceedings of the IEEE
86(11): 2278–2324.

Leathwick, J., Elith, J., Francis, M., Hastie, T. and Taylor, P. (2006). Vari-
ation in demersal ﬁsh species richness in the oceans surrounding new
zealand: an analysis using boosted regression trees, Marine Ecology
Progress Series 77: 802–813.

Leathwick, J., Rowe, D., Richardson, J., Elith, J. and Hastie, T. (2005).
Using multivariate adaptive regression splines to predict the distribu-
tions of New Zealand’s freshwater diadromous ﬁsh, Freshwater Biology
50: 2034–2051.

716

References

Leblanc, M. and Tibshirani, R. (1996). Combining estimates in regres-
sion and classiﬁcation, Journal of the American Statistical Association
91: 1641–1650.

LeCun, Y., Bottou, L., Bengio, Y. and Haﬀner, P. (1998). Gradient-based
learning applied to document recognition, Proceedings of the IEEE
86(11): 2278–2324.

Lee, D. and Seung, H. (1999). Learning the parts of objects by non-negative

matrix factorization, Nature 401: 788.

Lee, D. and Seung, H. (2001). Algorithms for non-negative matrix factor-
ization, Advances in Neural Information Processing Systems, (NIPS
2001), Vol. 13, Morgan Kaufman, Denver., pp. 556–562.

Lee, M.-L. (2004). Analysis of Microarray Gene Expression Data, Kluwer

Academic Publishers.

Lee, S.-I., Ganapathi, V. and Koller, D. (2007). Eﬃcient structure learning
of markov networks using l1-regularization, in B. Sch¨olkopf, J. Platt
and T. Hoﬀman (eds), Advances in Neural Information Processing
Systems 19, MIT Press, Cambridge, MA, pp. 817–824.

Leslie, C., Eskin, E., Cohen, A., Weston, J. and Noble, W. S. (2004). Mis-
match string kernels for discriminative protein classiﬁcation, Bioinfor-
matics 20(4): 467–476.

Levina, E. (2002). Statistical issues in texture analysis, PhD thesis, De-

partment. of Statistics, University of California, Berkeley.

Lin, H., McCulloch, C., Turnbull, B., Slate, E. and Clark, L. (2000). A
latent class mixed model for analyzing biomarker trajectories in lon-
gitudinal data with irregularly scheduled observations, Statistics in
Medicine 19: 1303–1318.

Lin, Y. and Zhang, H. (2006). Component selection and smoothing in
smoothing spline analysis of variance models, Annals of Statistics
34: 2272–2297.

Little, R. and Rubin, D. (2002). Statistical Analysis with Missing Data

(2nd Edition), Wiley, New York.

Lloyd, S. (1957). Least squares quantization in PCM., Technical report, Bell
Laboratories. Published in 1982 in IEEE Transactions on Information
Theory 28 128-137.

Loader, C. (1999). Local Regression and Likelihood, Springer, New York.

References

717

Loh, W. and Vanichsetakul, N. (1988). Tree structured classiﬁcation via
generalized discriminant analysis, Journal of the American Statistical
Association 83: 715–728.

Lugosi, G. and Vayatis, N. (2004). On the bayes-risk consistency of regu-

larized boosting methods, Annals of Statistics 32(1): 30–55.

Macnaughton Smith, P., Williams, W., Dale, M. and Mockett, L. (1965).
Dissimilarity analysis: a new technique of hierarchical subdivision, Na-
ture 202: 1034–1035.

MacKay, D. (1992). A practical Bayesian framework for backpropagation

neural networks, Neural Computation 4: 448–472.

MacQueen, J. (1967). Some methods for classiﬁcation and analysis of mul-
tivariate observations, Proceedings of the Fifth Berkeley Symposium
on Mathematical Statistics and Probability, eds. L.M. LeCam and J.
Neyman, University of California Press, pp. 281–297.

Madigan, D. and Raftery, A. (1994). Model selection and accounting for
model uncertainty using Occam’s window, Journal of the American
Statistical Association 89: 1535–46.

Mardia, K., Kent, J. and Bibby, J. (1979). Multivariate Analysis, Academic

Press.

Mason, L., Baxter, J., Bartlett, P. and Frean, M. (2000). Boosting algo-

rithms as gradient descent, 12: 512–518.

Massart, D., Plastria, F. and Kaufman, L. (1983). Non-hierarchical clus-
tering with MASLOC, The Journal of the Pattern Recognition Society
16: 507–516.

McCullagh, P. and Nelder, J. (1989). Generalized Linear Models, Chapman

and Hall, London.

McCulloch, W. and Pitts, W. (1943). A logical calculus of the ideas immi-
nent in nervous activity, Bulletin of Mathematical Biophysics 5: 115–
133. Reprinted in Anderson and Rosenfeld (1988), pp 96-104.

McLachlan, G. (1992). Discriminant Analysis and Statistical Pattern

Recognition, Wiley, New York.

Mease, D. and Wyner, A. (2008). Evidence contrary to the statistical view
of boosting (with discussion), Journal of Machine Learning Research
9: 131–156.

Meinshausen, N. (2007). Relaxed lasso, Computational Statistics and Data

Analysis 52(1): 374–393.

718

References

Meinshausen, N. and B¨uhlmann, P. (2006). High-dimensional graphs and
variable selection with the lasso, Annals of Statistics 34: 1436–1462.

Meir, R. and R¨atsch, G. (2003). An introduction to boosting and leverag-
ing, in S. Mendelson and A. Smola (eds), Lecture notes in Computer
Science, Advanced Lectures in Machine Learning, Springer, New York.

Michie, D., Spiegelhalter, D. and Taylor, C. (eds) (1994). Machine Learn-
ing, Neural and Statistical Classiﬁcation, Ellis Horwood Series in Ar-
tiﬁcial Intelligence, Ellis Horwood.

Morgan, J. N. and Sonquist, J. A. (1963). Problems in the analysis of survey
data, and a proposal, Journal of the American Statistical Association
58: 415–434.

Murray, W., Gill, P. and Wright, M. (1981). Practical Optimization, Aca-

demic Press.

Myles, J. and Hand, D. (1990). The multiclass metric problem in nearest

neighbor classiﬁcation, Pattern Recognition 23: 1291–1297.

Nadler, B. and Coifman, R. R. (2005). An exact asymptotic formula for the
error in CLS and in PLS: The importance of dimensional reduction in
multivariate calibration, Journal of Chemometrics 102: 107–118.

Neal, R. (1996). Bayesian Learning for Neural Networks, Springer, New

York.

Neal, R. and Hinton, G. (1998). A view of the EM algorithm that justiﬁes
incremental, sparse, and other variants; in Learning in Graphical Mod-
els, M. Jordan (ed.), Dordrecht: Kluwer Academic Publishers, Boston,
MA., pp. 355–368.

Neal, R. and Zhang, J. (2006). High dimensional classiﬁcation with
bayesian neural networks and dirichlet diﬀusion trees, in I. Guyon,
S. Gunn, M. Nikravesh and L. Zadeh (eds), Feature Extraction, Foun-
dations and Applications, Springer, New York, pp. 265–296.

Onton, J. and Makeig, S. (2006).

Information-based modeling of event-
related brain dynamics, in Neuper and Klimesch (eds), Progress in
Brain Research, Vol. 159, Elsevier, pp. 99–120.

Osborne, M., Presnell, B. and Turlach, B. (2000a). A new approach to
variable selection in least squares problems, IMA Journal of Numerical
Analysis 20: 389–404.

Osborne, M., Presnell, B. and Turlach, B. (2000b). On the lasso and its
dual, Journal of Computational and Graphical Statistics 9: 319–337.

Pace, R. K. and Barry, R. (1997). Sparse spatial autoregressions, Statistics

and Probability Letters 33: 291–297.

References

719

Page, L., Brin, S., Motwani, R. and Winograd, T. (1998).

The
to the web, Tech-
report, Stanford Digital Library Technologies Project.

pagerank citation ranking: bringing order
nical
http://citeseer.ist.psu.edu/page98pagerank.html.

Park, M. Y. and Hastie, T. (2007). l1-regularization path algorithm for gen-
eralized linear models, Journal of the Royal Statistical Society Series
B 69: 659–677.

Parker, D. (1985). Learning logic, Technical Report TR-87, Cambridge MA:
MIT Center for Research in Computational Economics and Manage-
ment Science.

Parmigiani, G., Garett, E. S., Irizarry, R. A. and Zeger, S. L. (eds) (2003).

The Analysis of Gene Expression Data, Springer, New York.

Paul, D., Bair, E., Hastie, T. and Tibshirani, R. (2008). “Pre-conditioning”
for feature selection and regression in high-dimensional problems, An-
nals of Statistics 36(4): 1595–1618.

Pearl, J. (1986). On evidential reasoning in a hierarchy of hypotheses,

Artiﬁcial Intelligence 28: 9–15.

Pearl, J. (1988). Probabilistic reasoning in intelligent systems: networks of

plausible inference, Morgan Kaufmann, San Francisco, CA.

Pearl, J. (2000). Causality: Models, Reasoning and Inference, Cambridge

University Press.

Peterson and Anderson, J. R. (1987). A mean ﬁeld theory learning algo-

rithm for neural networks, Complex Systems 1: 995–1019.

Petricoin, E. F., Ardekani, A. M., Hitt, B. A., Levine, P. J., Fusaro, V.,
Steinberg, S. M., Mills, G. B., Simone, C., Fishman, D. A., Kohn,
E. and Liotta, L. A. (2002). Use of proteomic patterns in serum to
identify ovarian cancer, Lancet 359: 572–577.

Platt, J. (1999). Fast Training of Support Vector Machines using Sequen-
tial Minimal Optimization; in Advances in Kernel Methods—Support
Vector Learning, B. Sch¨olkopf and C. J. C. Burges and A. J. Smola
(eds), MIT Press, Cambridge, MA., pp. 185–208.

Quinlan, R. (1993). C4.5: Programs for Machine Learning, Morgan Kauf-

mann, San Mateo.

Quinlan, R. (2004). C5.0, www.rulequest.com.

720

References

Ramaswamy, S., Tamayo, P., Rifkin, R., Mukherjee, S., Yeang, C., Angelo,
M., Ladd, C., Reich, M., Latulippe, E., Mesirov, J., Poggio, T., Gerald,
W., Loda, M., Lander, E. and Golub, T. (2001). Multiclass cancer
diagnosis using tumor gene expression signature, PNAS 98: 15149–
15154.

Ramsay, J. and Silverman, B. (1997). Functional Data Analysis, Springer,

New York.

Rao, C. R. (1973). Linear Statistical Inference and Its Applications, Wiley,

New York.

R¨atsch, G. and Warmuth, M. (2002). Maximizing the margin with boost-
ing, Proceedings of the 15th Annual Conference on Computational
Learning Theory, pp. 334–350.

Ravikumar, P., Liu, H., Laﬀerty, J. and Wasserman, L. (2008). Spam:
Sparse additive models, in J. Platt, D. Koller, Y. Singer and S. Roweis
(eds), Advances in Neural Information Processing Systems 20, MIT
Press, Cambridge, MA, pp. 1201–1208.

Ridgeway, G. (1999). The state of boosting, Computing Science and Statis-

tics 31: 172–181.

Rieger, K., Hong, W., Tusher, V., Tang, J., Tibshirani, R. and Chu, G.
(2004). Toxicity from radiation therapy associated with abnormal
transcriptional responses to DNA damage, Proceedings of the National
Academy of Sciences 101: 6634–6640.

Ripley, B. D. (1996). Pattern Recognition and Neural Networks, Cambridge

University Press.

Rissanen, J. (1983). A universal prior for integers and estimation by mini-

mum description length, Annals of Statistics 11: 416–431.

Robbins, H. and Munro, S. (1951). A stochastic approximation method,

Annals of Mathematical Statistics 22: 400–407.

Roosen, C. and Hastie, T. (1994). Automatic smoothing spline projection
pursuit, Journal of Computational and Graphical Statistics 3: 235–248.

Rosenblatt, F. (1958). The perceptron: a probabilistic model for infor-
mation storage and organization in the brain, Psychological Review
65: 386–408.

Rosenblatt, F. (1962). Principles of Neurodynamics: Perceptrons and the

Theory of Brain Mechanisms, Spartan, Washington, D.C.

References

721

Rosenwald, A., Wright, G., Chan, W. C., Connors, J. M., Campo, E.,
Fisher, R. I., Gascoyne, R. D., Muller-Hermelink, H. K., Smeland,
E. B. and Staudt, L. M. (2002). The use of molecular proﬁling to
predict survival after chemotherapy for diﬀuse large b-cell lymphoma,
The New England Journal of Medicine 346: 1937–1947.

Rosset, S. and Zhu, J. (2007). Piecewise linear regularized solution paths,

Annals of Statistics 35(3): 1012–1030.

Rosset, S., Zhu, J. and Hastie, T. (2004a). Boosting as a regularized path to
a maximum margin classiﬁer, Journal of Machine Learning Research
5: 941–973.

Rosset, S., Zhu, J. and Hastie, T. (2004b). Margin maximizing loss func-
tions, in S. Thrun, L. Saul and B. Sch¨olkopf (eds), Advances in Neural
Information Processing Systems 16, MIT Press, Cambridge, MA.

Rousseauw, J., du Plessis, J., Benade, A., Jordaan, P., Kotze, J., Jooste, P.
and Ferreira, J. (1983). Coronary risk factor screening in three rural
communities, South African Medical Journal 64: 430–436.

Roweis, S. T. and Saul, L. K. (2000). Locally linear embedding, Science

290: 2323–2326.

Rumelhart, D., Hinton, G. and Williams, R. (1986). Learning internal rep-
resentations by error propagation, in D. Rumelhart and J. McClelland
(eds), Parallel Distributed Processing: Explorations in the Microstruc-
ture of Cognition, The MIT Press, Cambridge, MA., pp. 318–362.

Sachs, K., Perez, O., Pe’er, D., Lauﬀenburger, D. and Nolan, G. (2005).
Causal protein-signaling networks derived from multiparameter single-
cell data, Science 308: 523–529.

Schapire, R. (1990). The strength of weak learnability, Machine Learning

5(2): 197–227.

Schapire, R. (2002). The boosting approach to machine learning: an
overview, in D. Denison, M. Hansen, C. Holmes, B. Mallick and B. Yu
(eds), MSRI workshop on Nonlinear Estimation and Classiﬁcation,
Springer, New York.

Schapire, R. and Singer, Y. (1999). Improved boosting algorithms using
conﬁdence-rated predictions, Machine Learning 37(3): 297–336.

Schapire, R., Freund, Y., Bartlett, P. and Lee, W. (1998). Boosting the
margin: a new explanation for the eﬀectiveness of voting methods,
Annals of Statistics 26(5): 1651–1686.

722

References

Sch¨olkopf, B., Smola, A. and M¨uller, K.-R. (1999). Kernel principal compo-
nent analysis, in B. Sch¨olkopf, C. Burges and A. Smola (eds), Advances
in Kernel Methods—Support Vector Learning, MIT Press, Cambridge,
MA, USA, pp. 327–352.

Schwarz, G. (1978). Estimating the dimension of a model, Annals of Statis-

tics 6(2): 461–464.

Scott, D. (1992). Multivariate Density Estimation: Theory, Practice, and

Visualization, Wiley, New York.

Seber, G. (1984). Multivariate Observations, Wiley, New York.

Segal, M. (2004). Machine learning benchmarks and random forest regres-
sion, Technical report, eScholarship Repository, University of Califor-
nia. http://repositories.edlib.org/cbmb/bench rf regn.

Shao, J. (1996). Bootstrap model selection, Journal of the American Sta-

tistical Association 91: 655–665.

Shenoy, P. and Shafer, G. (1988). An axiomatic framework for Bayesian
and belief-function propagation, AAAI Workshop on Uncertainty in
AI, North-Holland, pp. 307–314.

Short, R. and Fukunaga, K. (1981). The optimal distance measure for near-
est neighbor classiﬁcation, IEEE Transactions on Information Theory
27: 622–627.

Silverman, B. (1986). Density Estimation for Statistics and Data Analysis,

Chapman and Hall, London.

Silvey, S. (1975). Statistical Inference, Chapman and Hall, London.

Simard, P., Cun, Y. L. and Denker, J. (1993). Eﬃcient pattern recognition
using a new transformation distance, Advances in Neural Information
Processing Systems, Morgan Kaufman, San Mateo, CA, pp. 50–58.

Simon, R. M., Korn, E. L., McShane, L. M., Radmacher, M. D., Wright,
G. and Zhao, Y. (2004). Design and Analysis of DNA Microarray
Investigations, Springer, New York.

Sj¨ostrand, K., Rostrup, E., Ryberg, C., Larsen, R., Studholme, C., Baezner,
H., Ferro, J., Fazekas, F., Pantoni, L., Inzitari, D. and Waldemar,
G. (2007). Sparse decomposition and modeling of anatomical shape
variation, IEEE Transactions on Medical Imaging 26(12): 1625–1635.

Speed, T. and Kiiveri, H. T. (1986). Gaussian Markov distributions over

ﬁnite graphs, Annals of Statistics 14: 138–150.

References

723

Speed, T. (ed.) (2003). Statistical Analysis of Gene Expression Microarray

Data, Chapman and Hall, London.

Spiegelhalter, D., Best, N., Gilks, W. and Inskip, H. (1996). Hepatitis
B: a case study in MCMC methods, in W. Gilks, S. Richardson and
D. Spegelhalter (eds), Markov Chain Monte Carlo in Practice, Inter-
disciplinary Statistics, Chapman and Hall, London, pp. 21–43.

Spielman, D. A. and Teng, S.-H. (1996). Spectral partitioning works: Pla-
nar graphs and ﬁnite element meshes, IEEE Symposium on Founda-
tions of Computer Science, pp. 96–105.

Stamey, T., Kabalin, J., McNeal, J., Johnstone, I., Freiha, F., Redwine, E.
and Yang, N. (1989). Prostate speciﬁc antigen in the diagnosis and
treatment of adenocarcinoma of the prostate II radical prostatectomy
treated patients, Journal of Urology 16: 1076–1083.

Stone, C., Hansen, M., Kooperberg, C. and Truong, Y. (1997). Polynomial
splines and their tensor products (with discussion), Annals of Statistics
25(4): 1371–1470.

Stone, M. (1974). Cross-validatory choice and assessment of statistical
predictions, Journal of the Royal Statistical Society Series B 36: 111–
147.

Stone, M. (1977). An asymptotic equivalence of choice of model by cross-
validation and Akaike’s criterion, Journal of the Royal Statistical So-
ciety Series B. 39: 44–7.

Stone, M. and Brooks, R. J. (1990). Continuum regression: cross-validated
sequentially constructed prediction embracing ordinary least squares,
partial least squares and principal components regression (Corr: V54
p906-907), Journal of the Royal Statistical Society, Series B 52: 237–
269.

Storey, J. (2002). A direct approach to false discovery rates, Journal of the

Royal Statistical Society B. 64(3): 479–498.

Storey, J. (2003). The positive false discovery rate: A Bayesian interpreta-

tion and the q-value, Annals of Statistics 31: 2013–2025.

Storey, J. and Tibshirani, R. (2003). Statistical signiﬁcance for genomewide
studies, Proceedings of the National Academy of Sciences 100-: 9440–
9445.

Storey, J., Taylor, J. and Siegmund, D. (2004). Strong control, conservative
point estimation, and simultaneous conservative consistency of false
discovery rates: A uniﬁed approach., Journal of the Royal Statistical
Society, Series B 66: 187–205.

724

References

Surowiecki, J. (2004). The Wisdom of Crowds: Why the Many are Smarter
than the Few and How Collective Wisdom Shapes Business, Eco-
nomics, Societies and Nations., Little, Brown.

Swayne, D., Cook, D. and Buja, A. (1991). Xgobi: Interactive dynamic
graphics in the X window system with a link to S, ASA Proceedings
of Section on Statistical Graphics, pp. 1–8.

Tanner, M. and Wong, W. (1987). The calculation of posterior distribu-
tions by data augmentation (with discussion), Journal of the American
Statistical Association 82: 528–550.

Tarpey, T. and Flury, B. (1996). Self-consistency: A fundamental concept

in statistics, Statistical Science 11: 229–243.

Tenenbaum, J. B., de Silva, V. and Langford, J. C. (2000). A global
geometric framework for nonlinear dimensionality reduction, Science
290: 2319–2323.

Tibshirani, R. (1996). Regression shrinkage and selection via the lasso,
Journal of the Royal Statistical Society, Series B 58: 267–288.

Tibshirani, R. and Hastie, T. (2007). Margin trees for high-dimensional
classiﬁcation, Journal of Machine Learning Research 8: 637–652.

Tibshirani, R. and Knight, K. (1999). Model search and inference by boot-
strap “bumping, Journal of Computational and Graphical Statistics
8: 671–686.

Tibshirani, R. and Wang, P. (2007). Spatial smoothing and hot spot de-
tection for CGH data using the fused lasso, Biostatistics 9: 18–29.

Tibshirani, R., Hastie, T., Narasimhan, B. and Chu, G. (2001a). Diagnosis
of multiple cancer types by shrunken centroids of gene expression,
Proceedings of the National Academy of Sciences 99: 6567–6572.

Tibshirani, R., Hastie, T., Narasimhan, B. and Chu, G. (2003). Class
prediction by nearest shrunken centroids, with applications to DNA
microarrays, Statistical Science 18(1): 104–117.

Tibshirani, R., Saunders, M., Rosset, S., Zhu, J. and Knight, K. (2005).
Sparsity and smoothness via the fused lasso, Journal of the Royal
Statistical Society, Series B 67: 91–108.

Tibshirani, R., Walther, G. and Hastie, T. (2001b). Estimating the number
of clusters in a dataset via the gap statistic, Journal of the Royal
Statistical Society, Series B. 32(2): 411–423.

Tropp, J. (2004). Greed is good: algorithmic results for sparse approxima-
tion, IEEE Transactions on Information Theory 50: 2231– 2242.

References

725

Tropp, J. (2006). Just relax: convex programming methods for identify-
ing sparse signals in noise, IEEE Transactions on Information Theory
52: 1030–1051.

Valiant, L. G. (1984). A theory of the learnable, Communications of the

ACM 27: 1134–1142.

van der Merwe, A. and Zidek, J. (1980). Multivariate regression analysis
and canonical variates, The Canadian Journal of Statistics 8: 27–39.

Vapnik, V. (1996). The Nature of Statistical Learning Theory, Springer,

New York.

Vapnik, V. (1998). Statistical Learning Theory, Wiley, New York.

Vidakovic, B. (1999). Statistical Modeling by Wavelets, Wiley, New York.

von Luxburg, U. (2007). A tutorial on spectral clustering, Statistics and

Computing 17(4): 395–416.

Wahba, G. (1980). Spline bases, regularization, and generalized cross-
validation for solving approximation problems with large quantities
of noisy data, Proceedings of the International Conference on Approx-
imation theory in Honour of George Lorenz, Academic Press, Austin,
Texas, pp. 905–912.

Wahba, G. (1990). Spline Models for Observational Data, SIAM, Philadel-

phia.

Wahba, G., Lin, Y. and Zhang, H. (2000). GACV for support vector ma-
chines, in A. Smola, P. Bartlett, B. Sch¨olkopf and D. Schuurmans
(eds), Advances in Large Margin Classiﬁers, MIT Press, Cambridge,
MA., pp. 297–311.

Wainwright, M. (2006). Sharp thresholds for noisy and high-dimensional
recovery of sparsity using ℓ1-constrained quadratic programming,
Technical report, Department of Statistics, University of California,
Berkeley.

Wainwright, M. J., Ravikumar, P. and Laﬀerty, J. D. (2007). High-
dimensional graphical model selection using ℓ1-regularized logistic re-
gression, in B. Sch¨olkopf, J. Platt and T. Hoﬀman (eds), Advances
in Neural Information Processing Systems 19, MIT Press, Cambridge,
MA, pp. 1465–1472.

Wasserman, L. (2004). All of Statistics: a Concise Course in Statistical

Inference, Springer, New York.

Weisberg, S. (1980). Applied Linear Regression, Wiley, New York.

726

References

Werbos, P. (1974). Beyond Regression, PhD thesis, Harvard University.

Weston, J. and Watkins, C. (1999). Multiclass support vector machines, in
M. Verleysen (ed.), Proceedings of ESANN99, D. Facto Press, Brussels.

Whittaker, J. (1990). Graphical Models in Applied Multivariate Statistics,

Wiley, Chichester.

Wickerhauser, M. (1994). Adapted Wavelet Analysis from Theory to Soft-

ware, A.K. Peters Ltd, Natick, MA.

Widrow, B. and Hoﬀ, M. (1960). Adaptive switching circuits, IRE
WESCON Convention record, Vol. 4. pp 96-104; Reprinted in An-
dersen and Rosenfeld (1988).

Wold, H. (1975). Soft modelling by latent variables: the nonlinear iterative
partial least squares (NIPALS) approach, Perspectives in Probability
and Statistics, In Honor of M. S. Bartlett, pp. 117–144.

Wolpert, D. (1992). Stacked generalization, Neural Networks 5: 241–259.

Wu, T. and Lange, K. (2007). The MM alternative to EM, unpublished.

Wu, T. and Lange, K. (2008). Coordinate descent procedures for lasso
penalized regression, Annals of Applied Statistics 2(1): 224–244.

Yee, T. and Wild, C. (1996). Vector generalized additive models, Journal

of the Royal Statistical Society, Series B. 58: 481–493.

Yuan, M. and Lin, Y. (2007). Model selection and estimation in regression
with grouped variables, Journal of the Royal Statistical Society, Series
B 68(1): 49–67.

Zhang, P. (1993). Model selection via multifold cross-validation, Annals of

Statistics 21: 299–311.

Zhang, T. and Yu, B. (2005). Boosting with early stopping: convergence

and consistency, Annals of Statistics 33: 1538–1579.

Zhao, P. and Yu, B. (2006). On model selection consistency of lasso, Jour-

nal of Machine Learning Research 7: 2541–2563.

Zhao, P., Rocha, G. and Yu, B. (2008). The composite absolute penalties
for grouped and hierarchichal variable selection, Annals of Statistics.
(to appear).

Zhu, J. and Hastie, T. (2004). Classiﬁcation of gene microarrays by penal-

ized logistic regression, Biostatistics 5(2): 427–443.

Zhu, J., Zou, H., Rosset, S. and Hastie, T. (2005). Multiclass adaboost,

Unpublished.

References

727

Zou, H. (2006). The adaptive lasso and its oracle properties, Journal of

the American Statistical Association 101: 1418–1429.

Zou, H. and Hastie, T. (2005). Regularization and variable selection via
the elastic net, Journal of the Royal Statistical Society Series B.
67(2): 301–320.

Zou, H., Hastie, T. and Tibshirani, R. (2006). Sparse principal com-
ponent analysis, Journal of Computational and Graphical Statistics
15(2): 265–28.

Zou, H., Hastie, T. and Tibshirani, R. (2007). On the degrees of freedom

of the lasso, Annals of Statistics 35(5): 2173–2192.

728

References

Author Index

This is page 729
Printer: Opaque this

Abu-Mostafa, Y. 95, 474
Ackley, D. H. 645
Adam, B.-L. 664
Agrawal, R. 489–491, 578
Agresti, A. 385, 638, 640
Ahn, J. 695
Akaike, H. 257
Allen, D. 257
Ambroise, C. 247
Amit, Y. 602
Anderson, J. R. 641
Anderson, T. 645
Angelo, M. 654, 658
Ardekani, A. M. 664

Bach, F. 569
Baezner, H. 551
Bair, E. 676, 679–683, 693
Bakin, S. 90
Bakiri, G. 605, 606
Banerjee, O. 636
Barnhill, S. 658
Barron, A. 415
Barry, R. 371
Bartlett, P. 384, 615

Baskett, F. 480
Baxter, J. 384
Becker, R. 369
Bell, A. 578
Bellman, R. E. 22
Benade, A. 122
Bengio, Y. 404, 407, 408, 414, 644
Benjamini, Y. 687, 689, 693
Bentley, J. 480
Best, N. 292
Bibby, J. 94, 135, 441, 539, 559,
578, 630, 679

Bickel, P. 652
Bickel, P. J. 89
Bishop, C. 38, 233, 414, 623, 645
Bishop, Y. 629, 638
Bloomﬁeld, C. 663
Boser, B. 404, 414
Botha, J. 334
Bottou, L. 404, 407, 408, 414, 644
Boyd, S. 125, 632
Breiman, L. 85, 243, 251, 257, 292,
308, 310, 334, 339, 367,
384, 451, 453, 455, 554,
587, 602

730

Author Index

Bremaud, P. 577
Brin, S. 577
Brooks, R. J. 81
Brown, P. 679
Bruce, A. 181
B¨uhlmann, P. 87, 361, 384
Buja, A. 110, 297, 441, 446, 451,

455, 565, 574, 576, 578

Bunea, F. 91
Burges, C. 455
Butte, A. 631

Caligiuri, M. 663
Callow, M. 686, 693
Campo, E. 674
Candes, E. 86, 89, 613
Carlin, J. 292
Cazares, L. H. 664
Chambers, J. 334
Chan, W. C. 674
Chaudhuri, S. 631, 633
Chen, L. 574, 576, 578
Chen, S. S. 68, 94
Cherkassky, V. 38, 239, 257
Chu, G. 684, 693
Chui, C. 181
Clark, L. 331
Clark, M. 539
Clements, M. A. 664
Cleveland, W. 369
Cliﬀord, P. 629
Cohen, A. 668, 669
Coifman, R. R. 679
Coller, H. 663
Comon, P. 578
Connors, J. M. 674
Cook, D. 565, 578
Cook, N. 317
Copas, J. B. 94, 610
Cover, T. 257, 465, 481
Cox, D. 292, 645
Cressie, N. 171
Csiszar, I. 292
Cun, Y. L. 407, 471, 481
Cutler, A. 554

Dale, M. 526
Dasarathy, B. 480, 481
d’Aspremont, A. 636
Daubechies, I. 92, 181
Davis, J. W. 664
de Boor, C. 181
De Mol, C. 92
de Silva, V. 573
Defrise, M. 92
Dempster, A. 292, 449, 633
Denham, M. 679
Denker, J. 404, 407, 414, 471, 481
Devijver, P. 480
Dietterich, T. 286, 602, 605, 606,

623

Donath, W. E. 578
Donoho, D. 68, 86, 91, 94, 179,
181, 554, 613

Downing, J. 663
Drton, M. 631, 633
du Plessis, J. 122
Duan, N. 480
Dubes, R. 508, 522
Duchamp, T. 541
Duda, R. 38, 135
Dudoit, S. 686, 693
Duin, R. 624

Edwards, D. 645
Efron, B. 73, 86, 90, 94, 97, 98,
128, 231, 254, 257, 292,
334, 568, 609, 692, 693

Elad, M. 613
Elith, J. 375, 376, 378
Eskin, E. 668, 669
Evgeniou, T. 168, 181, 455

Fan, J. 92, 216, 539, 654
Fan, Y. 654
Fazekas, F. 551
Feng, Z. 664
Ferreira, J. 122
Ferro, J. 551
Fiedler, M. 578
Fienberg, S. 585, 629, 638

Finkel, R. 480
Fisher, N. 334
Fisher, R. A. 136, 455
Fisher, R. I. 674
Fisher, W. 310
Fishman, D. A. 664
Fix, E. 481
Flury, B. 578
Forgy, E. 578
Francis, M. 375, 376, 378
Frank, I. 81, 82, 94
Frean, M. 384
Freiha, F. 3, 49
Freund, Y. 337, 383, 384, 615
Fridlyand, J. 693
Friedman, J. 38, 81, 82, 85, 92–94,
111, 121, 126, 251, 257,
258, 308, 310, 334, 339,
345, 365, 367, 384, 391,
414, 437, 451, 453, 475,
480, 565, 578, 602, 611,
617–621, 623, 636, 657,
661, 667
Friedman, N. 629, 630, 645
Fu, W. 91, 92
Fukunaga, K. 475
Furnival, G. 57
Fusaro, V. 664

Gaasenbeek, M. 663
Ganapathi, V. 642
Gao, H. 181
Gascoyne, R. D. 674
Gelfand, A. 292
Gelman, A. 292
Geman, D. 292, 602
Geman, S. 292
Genkin, A. 661
Genovese, C. 693
Gerald, W. 654, 658
Gersho, A. 514, 515, 526, 578
Ghaoui, L. E. 636
Gijbels, I. 216
Gilks, W. 292
Gill, P. 96, 421

Author Index

731

Girosi, F. 168, 174, 181, 415
Golub, G. 257, 335, 535
Golub, T. 631, 654, 658, 663
Goodall, C. 578
Gordon, A. 578
Gray, R. 514, 515, 526, 578
Green, P. 181, 183, 334
Greenacre, M. 455
Greenshtein, E. 91
Guo, Y. 657
Guyon, I. 658

Haﬀner, P. 404, 407, 408, 414, 644
Hall, P. 292, 602, 619
Hammersley, J. M. 629
Hand, D. 135, 475
Hanley, J. 317
Hansen, M. 328
Hansen, R. 93
Hart, P. 38, 135, 465, 480, 481
Hartigan, J. A. 510, 578
Hastie, T. 72, 73, 78, 86, 88, 90,
92–94, 97, 98, 110, 121,
122, 126, 137, 174, 216,
257, 297, 299, 304, 334,
339, 345, 348, 349, 375,
376, 378, 384, 385, 414,
428, 431, 434, 437, 441,
446, 451, 455, 475, 478,
480, 481, 519, 539, 550,
565, 568, 578, 606, 609–
611, 614, 615, 636, 657,
658, 660–662, 664, 667,
676, 679–683, 693

Hatef, M. 624
Hathaway, R. J. 292
Heath, M. 257
Hebb, D. 414
Henderson, D. 404, 414
Herman, A. 334
Hertz, J. 414
Hinkley, D. 292
Hinton, G. 292, 334, 408, 414, 644,

645

Hitt, B. A. 664

732

Author Index

Ho, T. K. 602
Hochberg, Y. 687, 689, 693
Hodges, J. 481
Hoeﬂing, H. 92, 93, 642, 667
Hoerl, A. E. 64, 94
Hoﬀ, M. 396, 414
Hoﬀman, A. J. 578
Hofmann, H. 578
Holland, P. 629, 638
Hong, W. 684
Hothorn, T. 87, 361, 384
Howard, R. 404, 414
Huard, C. 663
Hubbard, W. 404, 414
Huber, P. 349, 414, 435, 565, 578
Hunter, D. 294
Hyv¨arinen, A. 560, 562, 578, 583

Ihaka, R. 455
Inskip, H. 292
Inzitari, D. 551
Izenman, A. 84

Jackel, L. 404, 414
Jacobs, R. 334
Jain, A. 508, 522
James, G. 606
Jancey, R. 578
Jensen, F. V. 629
Jiang, W. 384
Jirou´sek, R. 640
Johnson, N. 412
Johnstone, I. 3, 49, 73, 86, 94, 97,

98, 179, 181, 609, 613

Joliﬀe, I. T. 550
Jones, L. 415
Jones, M. 168, 174, 181, 415
Jooste, P. 122
Jordaan, P. 122
Jordan, M. 334, 569, 645

Kabalin, J. 3, 49
Kalbﬂeisch, J. 674, 693
Karhunen, J. 583
Kaski, S. 531, 532, 578

Kaufman, L. 517, 526, 578
Kearns, M. 380
Kennard, R. 64, 94
Kent, J. 94, 135, 441, 539, 559,
578, 630, 679

Kiiveri, H. T. 632
Kim, S.-J. 125
Kishon, E. 539
Kittler, J. 480, 624
Kleinberg, E. M. 602
Knight, K. 91, 292, 666, 693
Koh, K. 125
Kohane, I. 631
Kohavi, R. 243, 257
Kohn, E. 664
Kohonen, T. 462, 481, 531, 532,

578

Koller, D. 629, 630, 642, 645
Kooperberg, C. 328
Korn, E. L. 693
Kotze, J. 122
Kressel, U. 437
Krogh, A. 414

Ladd, C. 654, 658
Laﬀerty, J. 90, 304
Laﬀerty, J. D. 642
Lagus, K. 531, 532, 578
Laird, N. 292, 449
Lambert, D. 376
Lander, E. 654, 658, 663
Lange, K. 92, 294, 583, 584
Langford, J. C. 573
Larsen, R. 551
Latulippe, E. 654, 658
Lauﬀenburger, D. 625
Lauritzen, S. 629, 632, 645
Lawson, C. 93
Le Cun, Y. 404, 406–408, 414
Leathwick, J. 375, 376, 378
Leblanc, M. 292
LeCun, Y. 644
Lee, D. 552, 553
Lee, M.-L. 693
Lee, S.-I. 642

Lee, W. 384, 615
Leslie, C. 668, 669
Levina, E. 652, 693
Levine, P. J. 664
Lewis, D. 661
Li, K.-C. 480
Li, R. 92
Lin, H. 331
Lin, Y. 90, 304, 428, 455
Liotta, L. A. 664
Little, R. 332, 647
Littman, M. 578
Liu, H. 90, 304
Lloyd, S. 481, 578
Loader, C. 209, 216
Loda, M. 654, 658
Loh, M. 663
Loh, W. 310
Lugosi, G. 384

Ma, Y. 257
Macnaughton Smith, P. 526
MacKay, D. 623
MacQueen, J. 481, 578
Madigan, D. 257, 292, 661
Makeig, S. 564, 565
Mannila, H. 489–491, 578
Mardia, K. 94, 135, 441, 539, 559,
578, 630, 679

Marron, J. 695
Mason, L. 384
Massart, D. 517
Matas, J. 624
McCullagh, P. 638, 640
McCulloch, C. 331
McCulloch, W. 414
McLachlan, G. 135, 247
McNeal, J. 3, 49
McNeil, B. 317
McShane, L. M. 693
Mease, D. 384, 603
Meinshausen, N. 91, 635, 642
Meir, R. 384
Mesirov, J. 654, 658, 663
Mills, G. B. 664

Author Index

733

Mockett, L. 526
Morgan, J. N. 334
Motwani, R. 577
Mukherjee, S. 654, 658
Mulier, F. 38, 239
Muller-Hermelink, H. K. 674
M¨uller, K.-R. 547, 548
Munro, S. 397
Murray, W. 96, 421
Myles, J. 475

Nadler, B. 679
Narasimhan, B. 693
Neal, R. 268, 292, 409–412, 414,

605, 623

Nelder, J. 638, 640
Noble, W. S. 668, 669
Nolan, G. 625
Nowlan, S. 334

Oja, E. 560, 562, 578, 583
Olesen, K. G. 629
Olshen, R. 251, 308, 310, 334, 367,

451, 453
Onton, J. 564, 565
Osborne, M. 76, 94
Osindero, S. 644

Paatero, A. 531, 532, 578
Pace, R. K. 371
Page, L. 577
Palmer, R. 414
Pantoni, L. 551
Park, M. Y. 94, 126, 661
Parker, D. 414
Paul, D. 676, 679–683, 693
Pearl, J. 629, 645
Pe’er, D. 625
Perez, O. 625
Peterson 641
Petricoin, E. F. 664
Pitts, W. 414
Plastria, F. 517
Platt, J. 453
Poggio, T. 168, 174, 181, 415, 455,

654, 658

734

Author Index

Pontil, M. 168, 181, 455
Popescu, B. 617–619, 621, 623
Prentice, R. 674, 693
Presnell, B. 76, 94
Pˇreuˇcil, S. 640

Qu, Y. 664
Quinlan, R. 312, 334, 624

Radmacher, M. D. 693
Raftery, A. 257, 292
Ramaswamy, S. 654, 658
Ramsay, J. 181, 578
Rao, C. R. 455
R¨atsch, G. 384, 615
Ravikumar, P. 90, 304, 642
Redwine, E. 3, 49
Reich, M. 654, 658
Richardson, J. 375
Richardson, T. S. 631, 633
Ridgeway, G. 361
Rieger, K. 684
Rifkin, R. 654, 658
Ripley, B. D. 38, 131, 135, 136,
234, 308, 310, 400, 414,
415, 455, 468, 480, 481,
641, 645

Rissanen, J. 257
Ritov, Y. 89, 91
Robbins, H. 397
Rocha, G. 90
Roosen, C. 414
Rosenblatt, F. 102, 129, 414
Rosenwald, A. 674
Rosset, S. 89, 98, 348, 349, 385,
426, 428, 434, 610, 611,
615, 657, 661, 664, 666,
693

Rostrup, E. 551
Rousseauw, J. 122
Rousseeuw, P. 517, 526, 578
Rowe, D. 375
Roweis, S. T. 573
Rubin, D. 292, 332, 449, 647
Rumelhart, D. 414

Ryberg, C. 551

Saarela, A. 531, 532, 578
Sachs, K. 625
Saloj¨arvi, J. 531, 532, 578
Saul, L. K. 573
Saunders, M. 68, 94, 666, 693
Schapire, R. 337, 380, 383, 384,

615

Schellhammer, P. F. 664
Schnitzler, C. 334
Sch¨olkopf, B. 547, 548
Schroeder, A. 391
Schwarz, G. 233, 257
Scott, D. 216
Seber, G. 94
Segal, M. 596
Sejnowski, T. 578, 645
Semmes, O. J. 664
Seung, H. 552, 553
Shafer, G. 629
Shao, J. 257
Shenoy, P. 629
Short, R. 475
Shustek, L. 480
Shyu, M. 369
Siegmund, D. 689
Silverman, B. 181, 183, 216, 334,
486, 567, 578

Silvey, S. 292
Simard, P. 407, 471, 480, 481
Simon, R. M. 693
Simone, C. 664
Singer, Y. 384
Sj¨ostrand, K. 551
Slate, E. 331
Slonim, D. 631, 663
Smeland, E. B. 674
Smith, A. 292
Smola, A. 547, 548
Sonquist, J. A. 334
Spector, P. 243, 257
Speed, T. 632, 686, 693
Spiegelhalter, D. 292, 629
Spiegelman, C. 679

Spielman, D. A. 578
Srikant, R. 489–491, 578
Stamey, T. 3, 49
Staudt, L. M. 674
Steinberg, S. M. 664
Stern, H. 292
Stodden, V. 554
Stone, C. 251, 308, 310, 328, 334,
367, 451, 453

Stone, M. 81, 257
Storey, J. 689, 692, 693, 697, 698
Stork, D. 38, 135
Studholme, C. 551
Stuetzle, W. 391, 414, 541, 578
Surowiecki, J. 286
Swayne, D. 565, 578

Tamayo, P. 631, 654, 658, 663
Tang, J. 684
Tanner, M. 292
Tao, T. 89, 613
Tarpey, T. 578
Taylor, J. 88, 94, 610, 614, 689
Taylor, P. 375, 376, 378
Teh, Y.-W. 644
Tenenbaum, J. B. 573
Teng, S.-H. 578
Thomas, J. 257
Tibshirani, R. 73, 78, 86, 88, 90,
92–94, 97, 98, 110, 121,
122, 126, 137, 216, 257,
292, 297, 299, 304, 334,
339, 345, 384, 428, 431,
434, 437, 441, 446, 451,
455, 475, 478, 480, 481,
519, 550, 565, 568, 609–
611, 614, 636, 642, 657,
658, 660, 661, 666, 667,
676, 679–684, 692, 693

Toivonen, H. 489–491, 578
Traskin, M. 384
Trendaﬁlov, N. T. 550
Tropp, J. 91
Truong, Y. 328
Tsybakov, A. 89, 91

Author Index

735

Tukey, J. 414, 565, 578
Turlach, B. 76, 94
Turnbull, B. 331
Tusher, V. 684, 692
Tusn´ady, G. 292

Uddin, M. 550

Valiant, L. G. 380
van der Merwe, A. 84
Van Loan, C. 335, 535
Vandenberghe, L. 632
Vanichsetakul, N. 310
Vapnik, V. 38, 102, 132, 135, 171,

257, 438, 455, 658

Vayatis, N. 384
Vazirani, U. 380
Verkamo, A. I. 489–491, 578
Vidakovic, B. 181
von Luxburg, U. 578

Wahba, G. 168, 169, 181, 257, 268,
428, 429, 455

Wainwright, M. 91
Wainwright, M. J. 642
Waldemar, G. 551
Walther, G. 88, 94, 519, 610, 614
Wang, P. 667
Ward, M. D. 664
Warmuth, M. 615
Wasserman, L. 90, 304, 626, 645,

693

Watkins, C. 658
Wegkamp, M. 91
Weisberg, S. 94
Werbos, P. 414
Wermuth, N. 645
Weston, J. 658, 668, 669
Whittaker, J. 632, 633, 641, 645
Wickerhauser, M. 181
Widrow, B. 396, 414
Wild, C. 300
Williams, R. 414
Williams, W. 526
Wilson, R. 57

736

Author Index

Winograd, T. 577
Wold, H. 94
Wolpert, D. 292
Wong, M. A. 510
Wong, W. 292
Wright, G. 664, 674, 693
Wright, M. 96, 421
Wu, T. 92, 294, 583
Wyner, A. 384, 603

Yang, N. 3, 49
Yang, Y. 686, 693
Yasui, Y. 664
Yeang, C. 654, 658
Yee, T. 300
Yekutieli, Y. 693
Yu, B. 90, 91, 384
Yuan, M. 90

Zhang, H. 90, 304, 428, 455
Zhang, J. 409–412, 605
Zhang, P. 257
Zhang, T. 384
Zhao, P. 90, 91
Zhao, Y. 693
Zhu, J. 89, 98, 174, 348, 349, 385,
426, 428, 434, 610, 611,
615, 657, 661, 664, 666,
693
Zidek, J. 84
Zou, H. 72, 78, 92, 349, 385, 550,
662, 693

Index

This is page 737
Printer: Opaque this

L1 regularization, see Lasso

Activation function, 392–395
AdaBoost, 337–346
Adaptive lasso, 92
Adaptive methods, 429
Adaptive nearest neighbor meth-
ods, 475–478
Adaptive wavelet ﬁltering, 181
Additive model, 295–304
Adjusted response, 297
Aﬃne set, 130
Aﬃne-invariant average, 482, 540
AIC, see Akaike information cri-

terion

Akaike information criterion (AIC),

230

Analysis of deviance, 124
Applications

abstracts, 672
aorta, 204
bone, 152
California housing, 371–372,

591
countries, 517

demographics, 379–380
document, 532
ﬂow cytometry, 637
galaxy, 201
heart attack, 122, 146, 207
lymphoma, 674
marketing, 488
microarray, 5, 505, 532
nested spheres, 590
New Zealand ﬁsh, 375–379
nuclear magnetic resonance,

176
ozone, 201
prostate cancer, 3, 49, 61, 608
protein mass spectrometry, 664
satellite image, 470
skin of the orange, 429–432
spam, 2, 300–304, 313, 320,

328, 352, 593

vowel, 440, 464
waveform, 451
ZIP code, 4, 404, 536–539

Archetypal analysis, 554–557
Association rules, 492–495, 499–

501

738

Index

Automatic relevance determination,

411

Automatic selection of smoothing
parameters , 156

B-Spline, 186
Back-propagation, 392–397, 408–

409
Backﬁtting, 297, 391
Backward

selection, 58
stepwise selection, 59

Backward pass, 396
Bagging, 282–288, 409, 587
Basis expansions and regulariza-
tion, 139–189
Basis functions, 141, 186, 189, 321,

328
Batch learning, 397
Baum–Welch algorithm, 272
Bayes

classiﬁer, 21
factor, 234
methods, 233–235, 267–272
rate, 21

Bayesian, 409
Bayesian information criterion (BIC),

233

Benjamini–Hochberg method, 688
Best-subset selection, 57, 610
Between class covariance matrix,

114

Bias, 16, 24, 37, 160, 219
Bias-variance decomposition, 24,

37, 219

Bias-variance tradeoﬀ, 37, 219
BIC, see Bayesian Information Cri-

terion

Boltzmann machines, 638–648
Bonferroni method, 686
Boosting, 337–386, 409

as lasso regression, 607–609
exponential loss and AdaBoost,

343

implementations, 360
margin maximization, 613
numerical optimization, 358
partial-dependence plots, 369
regularization path, 607
shrinkage, 364
stochastic gradient boosting,

365
tree size, 361
variable importance, 367
Bootstrap, 249, 261–264, 267, 271–

282, 587

relationship to Bayesian method,

271

relationship to maximum like-
lihood method, 267

Bottom-up clustering, 520–528
Bump hunting, see Patient rule

induction method

Bumping, 290–292

C5.0, 624
Canonical variates, 441
CART, see Classiﬁcation and re-
gression trees
Categorical predictors, 10, 310
Censored data, 674
Classical multidimensional scaling,

570

Classiﬁcation, 22, 101–137, 305–
317, 417–429
Classiﬁcation and regression trees

(CART), 305–317

Clique, 628
Clustering, 501–528

k-means, 509–510
agglomerative, 523–528
hierarchical, 520–528

Codebook, 515
Combinatorial algorithms, 507
Combining models, 288–290
Committee, 289, 587, 605
Comparison of learning methods,

350–352

gradient boosting, 358

Complete data, 276

Complexity parameter, 37
Computational shortcuts

quadratic penalty, 659
Condensing procedure, 480
Conditional likelihood, 31
Confusion matrix, 301
Conjugate gradients, 396
Consensus, 285–286
Convolutional networks, 407
Coordinate descent, 92, 636, 668
COSSO, 304
Cost complexity pruning, 308
Covariance graph, 631
Cp statistic, 230
Cross-entropy, 308–310
Cross-validation, 241–245
Cubic smoothing spline, 151–153
Cubic spline, 151–153
Curse of dimensionality, 22–26

Dantzig selector, 89
Data augmentation, 276
Daubechies symmlet-8 wavelets,

176

De-correlation, 597
Decision boundary, 13–15, 21
Decision trees, 305–317
Decoder, 515, see encoder
Decomposable models, 641
Degrees of freedom

in an additive model, 302
in ridge regression, 68
of a tree, 336
of smoother matrices, 153–154,

158

Delta rule, 397
Demmler-Reinsch basis for splines,

156

Density estimation, 208–215
Deviance, 124, 309
Diagonal linear discriminant anal-
ysis, 651–654

Dimension reduction, 658

for nearest neighbors, 479
Discrete variables, 10, 310–311

Index

739

Discriminant

adaptive nearest neighbor clas-

siﬁer, 475–480

analysis, 106–119
coordinates, 108
functions, 109–110

Dissimilarity measure, 503–504
Dummy variables, 10

Early stopping, 398
Eﬀective degrees of freedom, 17,

68, 153–154, 158, 232, 302,
336

Eﬀective number of parameters,
15, 68, 153–154, 158, 232,
302, 336

Eigenvalues of a smoother matrix,

154

Elastic net, 662
EM algorithm, 272–279

as a maximization-maximization

procedure, 277

for two component Gaussian

mixture, 272

Encoder, 514–515
Ensemble, 616–623
Ensemble learning, 605–624
Entropy, 309
Equivalent kernel, 156
Error rate, 219–230
Error-correcting codes, 606
Estimates of in-sample prediction

error, 230

Expectation-maximization algorithm,
see EM algorithm

Extra-sample error, 228

False discovery rate, 687–690, 692,

693

Feature, 1

extraction, 150
selection, 409, 658, 681–683
Feed-forward neural networks, 392–

408

740

Index

Fisher’s linear discriminant, 106–

119, 438

Flexible discriminant analysis, 440–

445

Forward

selection, 58
stagewise, 86, 608
stagewise additive modeling,

342
stepwise, 73

Forward pass algorithm, 395
Fourier transform, 168
Frequentist methods, 267
Function approximation, 28–36
Fused lasso, 666

Gap statistic, 519
Gating networks, 329
Gauss-Markov theorem, 51–52
Gauss-Newton method, 391
Gaussian (normal) distribution, 16
Gaussian graphical model, 630
Gaussian mixtures, 273, 463, 492,

509

Gaussian radial basis functions,

212

GBM, see Gradient boosting
GBM package, see Gradient boost-

ing

GCV, see Generalized cross-validation
GEM (generalized EM), 277
Generalization
error, 220
performance, 220

Generalized additive model, 295–

304

Generalized association rules, 497–

499

Generalized cross-validation, 244
Generalized linear discriminant anal-

ysis, 438

Generalized linear models, 125
Gibbs sampler, 279–280, 641

for mixtures, 280

Gini index, 309

Global Markov property, 628
Gradient Boosting, 359–361
Gradient descent, 358, 395–397
Graph Laplacian, 545
Graphical lasso, 636
Grouped lasso, 90

Haar basis function, 176
Hammersley-Cliﬀord theorem, 629
Hard-thresholding, 653
Hat matrix, 46
Helix, 582
Hessian matrix, 121
Hidden nodes, 641–642
Hidden units, 393–394
Hierarchical clustering, 520–528
Hierarchical mixtures of experts,

329–332

High-dimensional problems, 649
Hints, 96
Hyperplane, see Separating Hy-

perplane

ICA, see Independent components

analysis
Importance sampling, 617
In-sample prediction error, 230
Incomplete data, 332
Independent components analysis,

557–570
Independent variables, 9
Indicator response matrix, 103
Inference, 261–294
Information

Fisher, 266
observed, 274

Information theory, 236, 561
Inner product, 53, 668, 670
Inputs, 10
Instability of trees, 312
Intercept, 11
Invariance manifold, 471
Invariant metric, 471
Inverse wavelet transform, 179

IRLS, see Iteratively reweighted
least squares
Irreducible error, 224
Ising model, 638
ISOMAP, 572
Isometric feature mapping, 572
Iterative proportional scaling, 585
Iteratively reweighted least squares

(IRLS), 121

Jensen’s inequality, 293
Join tree, 629
Junction tree, 629

K-means clustering, 460, 509–514
K-medoid clustering, 515–520
K-nearest neighbor classiﬁers, 463
Karhunen-Loeve transformation (prin-

cipal components), 66–
67, 79, 534–539
Karush-Kuhn-Tucker conditions,

133, 420

Kernel

classiﬁcation, 670
density classiﬁcation, 210
density estimation, 208–215
function, 209
logistic regression, 654
principal component, 547–550
string, 668–669
trick, 660

Kernel methods, 167–176, 208–215,

423–438, 659

Knot, 141, 322
Kriging, 171
Kruskal-Shephard scaling, 570
Kullback-Leibler distance, 561

Lagrange multipliers, 293
Landmark, 539
Laplacian, 545
Laplacian distribution, 72
LAR, see Least angle regression
Lasso, 68–69, 86–90, 609, 635, 636,

661

Index

741

fused, 666

Latent

factor, 674
variable, 678

Learning, 1
Learning rate, 396
Learning vector quantization, 462
Least angle regression, 73–79, 86,

610
Least squares, 11, 32
Leave-one-out cross-validation, 243
LeNet, 406
Likelihood function, 265, 273
Linear basis expansion, 139–148
Linear combination splits, 312
Linear discriminant function, 106–

119

Linear methods

for classiﬁcation, 101–137
for regression, 43–99

Linear models and least squares,

11

Linear regression of an indicator

matrix, 103

Linear separability, 129
Linear smoother, 153
Link function, 296
LLE, see Local linear embedding
Local false discovery rate, 693
Local likelihood, 205
Local linear embedding, 572
Local methods in high dimensions,

22–27

Local minima, 400
Local polynomial regression, 197
Local regression, 194, 200
Localization in time/frequency, 175
Loess (local regression), 194, 200
Log-linear model, 639
Log-odds ratio (logit), 119
Logistic (sigmoid) function, 393
Logistic regression, 119–128, 299
Logit (log-odds ratio), 119
Loss function, 18, 21, 219–223, 346
Loss matrix, 310

742

Index

Lossless compression, 515
Lossy compression, 515
LVQ, see Learning Vector Quan-

tization

Mahalanobis distance, 441
Majority vote, 337
Majorization, 294, 553
Majorize-Minimize algorithm, 294,

584

MAP (maximum aposteriori) es-

timate, 270

Margin, 134, 418
Market basket analysis, 488, 499
Markov chain Monte Carlo (MCMC)

methods, 279

Markov graph, 627
Markov networks, 638–648
MARS, see Multivariate adaptive

regression splines

MART, see Multiple additive re-
gression trees
Maximum likelihood estimation,

31, 261, 265

MCMC, see Markov Chain Monte
Carlo Methods
MDL, see Minimum description

length

Mean ﬁeld approximation, 641
Mean squared error, 24, 285
Memory-based method, 463
Metropolis-Hastings algorithm, 282
Minimum description length (MDL),

235
Minorization, 294, 553
Minorize-Maximize algorithm, 294,

584

Misclassiﬁcation error, 17, 309
Missing data, 276, 332–333
Missing predictor values, 332–333
Mixing proportions, 214
Mixture discriminant analysis, 449–

455

Mixture of experts, 329–332
Mixtures and the EM algorithm,

272–275
MM algorithm, 294, 584
Mode seekers, 507
Model averaging and stacking, 288
Model combination, 289
Model complexity, 221–222
Model selection, 57, 222–223, 230–

231

Modiﬁed regression, 634
Monte Carlo method, 250, 495
Mother wavelet, 178
Multidimensional scaling, 570–572
Multidimensional splines, 162
Multiedit algorithm, 480
Multilayer perceptron, 400, 401
Multinomial distribution, 120
Multiple additive regression trees
(MART), 361
Multiple hypothesis testing, 683–

693

Multiple minima, 291, 400
Multiple outcome shrinkage and

selection, 84

Multiple outputs, 56, 84, 103–106
Multiple regression from simple uni-

variate regression, 52

Multiresolution analysis, 178
Multivariate adaptive regression
splines (MARS), 321–327
Multivariate nonparametric regres-

sion, 445

Nadaraya–Watson estimate, 193
Naive Bayes classiﬁer, 108, 210–

211, 694

Natural cubic splines, 144–146
Nearest centroids, 670
Nearest neighbor methods, 463–

483

Nearest shrunken centroids, 651–

654, 694

Mixture modeling, 214–215, 272–

275, 449–455, 692

Network diagram, 392
Neural networks, 389–416

Index

743

Newton’s method (Newton-Raphson

procedure), 120–122

Perceptron, 392–416
Piecewise polynomials and splines,

Non-negative matrix factorization,

36, 143

553–554

Posterior

Nonparametric logistic regression,

299–304

Normal (Gaussian) distribution,

16, 31

Normal equations, 12
Numerical optimization, 395–396

Object dissimilarity, 505–507
Online algorithm, 397
Optimal scoring, 445, 450–451
Optimal separating hyperplane, 132–

135

Optimism of the training error rate,

228–230

Ordered categorical (ordinal) pre-
dictor, 10, 504

Ordered features, 666
Orthogonal predictors, 53
Overﬁtting, 220, 228–230, 364

PageRank, 576
Pairwise distance, 668
Pairwise Markov property, 628
Parametric bootstrap, 264
Partial dependence plots, 369–370
Partial least squares, 80–82, 680
Partition function, 638
Parzen window, 208
Pasting, 318
Path algorithm, 73–79, 86–89, 432
Patient rule induction method(PRIM),

distribution, 268
probability, 233–235, 268

Power method, 577
Pre-conditioning, 681–683
Prediction accuracy, 329
Prediction error, 18
Predictive distribution, 268
PRIM, see Patient rule induction

method

Principal components, 66–67, 79–
80, 534–539, 547

regression, 79–80
sparse, 550
supervised, 674

Principal curves and surfaces, 541–

544
Principal points, 541
Prior distribution, 268–272
Procrustes

average, 540
distance, 539

Projection pursuit, 389–392, 565

regression, 389–392
Prototype classiﬁer, 459–463
Prototype methods, 459–463
Proximity matrices, 503
Pruning, 308

QR decomposition, 55
Quadratic approximations and in-

ference, 124

317–321, 499–501

Quadratic discriminant function,

Peeling, 318
Penalization, 607, see regulariza-

108, 110

tion

Radial basis function (RBF) net-

Penalized discriminant analysis, 446–

work, 392

449

Penalized polynomial regression,

171

Penalized regression, 34, 61–69, 171
Penalty matrix, 152, 189

Radial basis functions, 212–214,

275, 393
Radial kernel, 548
Random forest, 409, 587–604

algorithm, 588

744

Index

bias, 596–601
comparison to boosting, 589
example, 589
out-of-bag (oob), 592
overﬁt, 596
proximity plot, 595
variable importance, 593
variance, 597–601

Rao score test, 125
Rayleigh quotient, 116
Receiver operating characteristic

(ROC) curve, 317

Reduced-rank linear discriminant
analysis, 113

Regression, 11–14, 43–99, 200–204
Regression spline, 144
Regularization, 34, 167–176
Regularized discriminant analysis,

Separating hyperplanes, 136, 417–

419

Separator, 628
Shape average, 482, 540
Shrinkage methods, 61–69, 652
Sigmoid, 393
Signiﬁcance Analysis of Microar-
rays, 690–693
Similarity measure, see Dissimi-
larity measure
Single index model, 390
Singular value decomposition, 64,
535–536, 659

singular values, 535
singular vectors, 535
Sliced inverse regression, 480
Smoother, 139–156, 192–199

matrix, 153

112–113, 654

Smoothing parameter, 37, 156–161,

Relevance network, 631
Representer of evaluation, 169
Reproducing kernel Hilbert space,

167–176, 428–429
Reproducing property, 169
Responsibilities, 274–275
Ridge regression, 61–68, 650, 659
Risk factor, 122
Robust ﬁtting, 346–350
Rosenblatt’s perceptron learning
algorithm, 130

Rug plot, 303
Ruleﬁt, 623

SAM, 690–693, see Signiﬁcance Anal-
ysis of Microarrays

Sammon mapping, 571
SCAD, 92
Scaling of the inputs, 398
Schwarz’s criterion, 230–235
Score equations, 120, 265
Self-consistency property, 541–543
Self-organizing map (SOM), 528–

534

Sensitivity of a test, 314–317
Separating hyperplane, 132–135

198–199
Smoothing spline, 151–156
Soft clustering, 512
Soft-thresholding, 653
Softmax function, 393
SOM, see Self-organizing map
Sparse, 175, 304, 610–613, 636

additive model, 91
graph, 625, 635

Speciﬁcity of a test, 314–317
Spectral clustering, 544–547
Spline, 186

additive, 297–299
cubic, 151–153
cubic smoothing, 151–153
interaction, 428
regression, 144
smoothing, 151–156
thin plate, 165

Squared error loss, 18, 24, 37, 219
SRM, see Structural risk minimiza-

tion

Stacking (stacked generalization),

290
Starting values, 397
Statistical decision theory, 18–22

Index

745

Undirected graph, 625–648
Universal approximator, 390
Unsupervised learning, 2, 485–585
Unsupervised learning as super-
vised learning, 495–497

Validation set, 222
Vapnik-Chervonenkis (VC) dimen-

sion, 237–239
Variable importance plot, 594
Variable types and terminology, 9
Variance, 16, 25, 37, 158–161, 219

between, 114
within, 114, 446
Variance reduction, 588
Varying coeﬃcient models, 203–

204

VC dimension, see Vapnik–Chervon-
enkis dimension

Vector quantization, 514–515
Voronoi regions, 510

Wald test, 125
Wavelet

basis functions, 176–179
smoothing, 174
transform, 176–179
Weak learner, 383, 605
Weakest link pruning, 308
Webpages, 576
Website for book, 8
Weight decay, 398
Weight elimination, 398
Weights in a neural network, 395
Within class covariance matrix, 114,

446

Statistical model, 28–29
Steepest descent, 358, 395–397
Stepwise selection, 60
Stochastic approximation, 397
Stochastic search (bumping), 290–

292

Stress function, 570–572
Structural risk minimization (SRM),

239–241

Subset selection, 57–60
Supervised learning, 2
Supervised principal components,

674–681

Support vector classiﬁer, 417–421,

654
multiclass, 657

Support vector machine, 423–437
SURE shrinkage method, 179
Survival analysis, 674
Survival curve, 674
SVD, see Singular value decom-

position

Symmlet basis, 176

Tangent distance, 471–475
Tanh activation function, 424
Target variables, 10
Tensor product basis, 162
Test error, 220–223
Test set, 220
Thin plate spline, 165
Thinning strategy, 189
Trace of a matrix, 153
Training epoch, 397
Training error, 220–223
Training set, 219–223
Tree for regression, 307–308
Tree-based methods, 305–317
Trees for classiﬁcation, 308–310
Trellis display, 202

